strtotime is php function that can be used for this purpose.
strtotime — Parse about any English textual datetime description into a Unix timestamp
- Firstly get all the posts using meta key .
- Then get date value from meta field.
- Then convert to unix timestamp.
- Then update again.
$args = array( 'posts_per_page' => -1, 'meta_key' => 'meta_key_name' );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post );
$date = get_post_meta(get_the_id(), 'meta_key_name', true);
if( strtotime($date) != false ){ // To exclude dates which are already in timestamp
update_post_meta(get_the_id(), 'meta_key_name', strtotime($date));
}
endforeach;
wp_reset_postdata();?>
Related Posts:
- SQL Query to copy value of a meta_key into another meta_key
- How to correctly call custom field dates into a posts_where filter using SQL statements
- Add custom fields to search
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- How to rename a custom field?
- Date, Time, and Timezones
- Bulk move (or copy) from a custom field to the post content?
- Up/Down voting system for WordPress
- Custom Fields Bulk Edit
- custom field value date convert to unix timestamp problems
- Get all posts that do not have a specific custom field without using a subquery
- Order query by meta_value with multiple custom fields
- Custom Field Create Bulk via SQL Query
- How to add a new meta key and assign timestamp to posts
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Meta Query And/Or
- Get emails from users by custom field SQL
- SQL: Select wordpress posts with given text string and add a custom field to them?
- Show array of meta_value in Edit Post Coloum
- Change word in woocommerce product category custom field
- SQL query to change the value of a Custom Field
- searching by keywords in post’s metas or pagination links problem
- query specific posts according their custom fields, using sql SELECT
- Alter SQL query to return posts with unique custom field value, no duplicate values
- Update field name without losing the value
- Sqlite: CURRENT_TIMESTAMP is in GMT, not the timezone of the machine
- ORDER BY custom field value
- Using wordpress post data as input for google visualisations
- Order posts by custom field and if custom field is empty return remaining posts
- Can serialized arrays in DB be matched against serialized arrays with meta_query?
- Create a select drop down of available menus
- Adding a prefix to a post title
- copy attachments to another post type and change attachment url
- Cannot edit post meta fields with rest API
- Only display custom field if it there is a value inside
- Slow meta query with multi meta keys
- Custom Field Multiple Clauses
- Custom field values repeating
- Sorting posts by multiple values, combined
- Send Multiple Custom Field Values Through the URL
- $wp_query meta_key naming issue [closed]
- Meta_query and numeric comparison [closed]
- Separate table or usermeta
- Woocommerce with metabox plugin
- using multiple meta_key and meta_value in query_posts
- Json api does not return all metadata
- Use custom field as a variable
- Multiple relationships in a query
- ACF: How to get the full field name (meta_key) by a field key?
- How Meta Data is different from Custom Fields of POST/PAGE in WordPress
- global function to apply filter to custom field
- Print custom field in Query Loop block
- Is there a simpler version of WP Media?
- Order RSS content by an advanced custom field value
- Advanced search by two criteria – sort by location and date (ascending or descending)
- Alter main archive, to show posts with meta as last
- Add microdata from schema.org [closed]
- Displaying multiple URLs as custom field values
- Collect user custom field in product page woocommerce
- display custom field from inner blog in the main homepage of wordpress multisite
- Show user info in a hovercard [closed]
- Display Custom Meta Box Field Only If Value is Present
- WP Query – Is this correct?
- edit_tag_form_fields is depricated but tag_edit_form_fields doesn’t work
- Iterate through users and display users meta info at front-page
- Adding custom field and querying from post table
- How to display a product features dynamically with icons?
- Access ACF fields within custom preview function?
- Can I access Posts of custom-fields via URL?
- Custom field image to Featured Image
- plugin-list-category-post custom fields
- Working with multiple values and metaboxes
- Unable to select image with custom field
- How to automatically change a posts status to draft based on custom field
- How to show ACF fields in Gridbuilder custom block
- Move the metaboxes to the very top of post editor
- WordPress Rest API custom field not updating till i manually update the post
- search based on custom field
- Why isn’t update_post_meta saving?
- Custom fields multiple commas separated values
- Display taxonomy loop using custom field data
- Add custom field information to source meta data
- use mysql to replace one custom field value with another custom field value
- Change blog post title on main blog page
- Spit out list of distinct instances of custom field?
- Delete custom meta
- Filter and display a specific custom field value [closed]
- Custom Field select list is truncated
- Query Posts Via WordPress URL
- wp_postmeta are updated for only one page
- How to add a prefix to existing custom fields over MYSQL query?
- Complex WP_Query Using Post Date And Post Meta
- Upload image to wordpress
- I want to add a custom field in the rss title of each post, but don’t want it to be shown on the site
- Custom metaboxes not saving after switching themes
- Semi-Private Comments + page comments -> is it possible?
- Dynamically create check boxes for given post titles in WPAlchemy
- Assign custom fields to multiple posts?
- Get fields from metabox array
- How I can change PayPal IPN ‘custom’ field in woocommerce?