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
- How to fix missing custom fields after upgrading to WordPress 4.8.1?
- Preserving line breaks when saving and displaying custom fields data
- With WordPress Importer, why can’t I import post meta containing a multi-dimensional array, in which value(s) of that array contain line breaks?
- How to prevent custom fields from being cleared during a bulk edit?
- Is there a hook / action that is triggered when adding or removing a post thumbnail?
- Get custom field values into the sidebar/widget?
- Custom fields are not restored to previous revisions
- Multiple custom fields with the same name
- Execute/Parse Shortcode in Native WordPress Custom Field Value Field
- Displaying Custom Fields on Post with Genesis Child Theme
- Custom fields: In what order are they saved into the DB?
- Metabox image upload and custom field
- How to add a title field in comments?
- Inserting Schema Markup (JSON-LD) Manually with Custom Fields or any Better Ways?
- Force hide custom field metaboxes
- Custom Fields Code not echoing whats in the value field
- Meta query with timestamp using WP_query
- Passing Custom Field Data as Array to be Saved (Resulting Custom Field Array is inconsistent)
- load custom fields on click
- Add Custom Field to a template page backend
- custom field not saved
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Auto-remove custom field with no value on publish
- Custom Fields box in the post editor: Replace textareas with input elements
- Hide custom meta data if empty
- Passing args to WP_User_Query am I using meta correctly?
- How to get latest post value if first post is empty in wordpress
- Custom fields attached to a page template only show on edit screen when page is saved
- Value from custom field is not being displayed?
- Can I access a post meta field before the loop?
- wrap text around custom fields array
- Displaying page image in the footer automatically
- Hide custom column in admin template screen (Elementor) [closed]
- ORDER BY custom field value out of where clause
- Show image if author meta (profile fields) exists outside loop
- How can i retrive a text from a custom field
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- Is it possible to populate a custom field with content from a page
- Buik update custom field values from external API
- Change a custom field value after X number of seconds
- How to put forward a blog post
- Let Users Filter Posts by Custom Fields
- Jquery on custom-field backend
- Display latest post depending on Meta Box content
- Custom fields won’t update
- How to use custom fields like Title to show value in content?
- Populate custom checkout fields with data from previous orders
- Expire Date Condition not Working ACF WordPress
- Making custom meta box required (with error message if not filled in) on Gutenberg
- Is the use of many custom field not good for server?
- Changing form action based on selected value
- Very large list of options for BuddyPress profile fields
- Change Order of Sections Using Custom Fields
- How to add content with a filter when there’s no content in the editor
- Text in header as a page – hide from Web crawlers
- When post is updated, custom metadata in text area field is overwritten
- custom select field populated by allocated post category
- Help sorting by Meta Key value
- Custom classes for attachments
- Adding thumbnails for non-image attachments
- List custom field values in alphabetical order without repetition from the current category?
- Incorrect data after modifying post using backlink from wp_die
- Displaying shortcode content inside custom field without images
- Hard Define Custom Field Value
- get adjacent post by meta key and meta value
- How to mark a image attachment as background image?
- Custom fields: Split data from single custom field’s sub-array to separate custom fields when saving post
- How can I copy value from dropdown once I select it to text area as text?
- Create taxonomy terms from custom field values
- Save Custom Meta Value on Media Upload
- Is there a way to read JSON data inside Custom Fields without editing PHP? [closed]
- How to add new Metadata options (Date, Author, etc.) for Posts?
- Saving multiple custom meta box fields
- Modal pop-up HTML code works on other sites or HTML viewers but not in the custom HTML block within a wordpress page?
- Automatically changing a posts status to draft based on magic fields [closed]