You should save the date in a format that is unambiguous so you will get predictable results. The particular format you prefer can’t be parsed by strtotime because it’s not clear which is the month, day, and year. If you convert the date when the meta data is saved, the contents of the field will change to that format and upon second save will become unparseable. It’s better to save it in a clear format and convert it when it’s output to your template.
You can simplify things for your client and be sure that the format will always be parseable by adding a date picker to the meta field that enforces a particular format. This script makes it very easy. Then, in your template:
$your_meta_field_contents="January 23 2012";
$time = strtotime( $your_meta_field_contents );
echo date( 'm d y', $time );
Related Posts:
- Add additional field to custom post_type
- Help Creating a Slideshow Custom Post Type with Custom Meta Boxes?
- Custom Post Type – Taxonomy Dropdown Menu?
- Search that will look in custom field, post title and post content
- How can I add a column/s to wp_posts table?
- echo value from ‘select’ field type into page template using cmb2?
- How to get custom metabox image field?
- Detect meta value changes when post is updated (post_updated)
- Custom field being erased after autosave
- Order custom posts by a date metabox
- How to select one major category (or custom taxonomy) for a custom post type?
- How to sort CPT by custom meta value (date), and return posts month by month
- Use Custom Post Type as Custom Field
- Saving multiple Metabox contents
- How to save the checked boxes?
- Metabox saving values
- WP insert post PHP function dynamically generated Custom Fields
- add_meta_box: Datepicker like the one for postdate?
- Displaying Meta Box Image
- Multiple information using custom post type
- how to set default value for checkbox in wordpress
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Using WPAlchemy metabox values in another metabox
- Display custom post on home page based on a metabox selection
- Conditional to modify query results
- Create a random unique 6 digit number as custom field for custom post type
- Why do I lose the content of meta boxes when I leave the page?
- Dynamically add / duplicate custom meta in custom post types
- Using several custom fields as custom post title
- WordPress custom meta field for custom post not storing data
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- How to Duplicate (multiple meta box)?
- window.send_to_editor and jQuery .attr() conflicts with multiple custom upload image meta boxes
- List of Posts in a Custom Field
- Save an array from drop-down in custom meta box
- Populate Custom Fields in a Custom Post Type?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- What’s the difference between same wp functions get_posts(); functions in different form?
- Keep display metadata value on backend – Custom Metabox
- Push metadata in array
- Troubles with saving metabox
- How to check if user meta field is empty in conditional else statement
- Replace text in post from cvs
- Why is my select meta data not saving?
- dynamically add a custom field or metabox to custom post type [duplicate]
- Query & Order posts by custom fields
- Visual editor issue by having multiple tiny mce editors in a CPT
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- A better way to add a meta box to custom post types
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Plugin – Combine Meta Box Input Fields into single saveble record
- get_post_meta not working on publishing
- Using custom field content as expression in IF statement [closed]
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Grouping metadatas into one
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Cannot save CPT meta box
- Adding Page Templates to post but it ignored it
- Displaying custom field according to date
- Permalinks: custom structure for taxonomy – tags?
- How can I move (or create another) publish button?
- Custom “radio button meta box” not saving correctly
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- Custom Post Meta from custom metaboxes is randomly being deleted
- Add a custom meta box for client to order CPT posts how they want
- Alike Shortcode using in Custom Shortcode
- Query custom post type that has a serialized relational advanced custom field value
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- Sort custom post column by generated value?
- when looping through custom post data not appearing
- How to avoid duplicate posts queried from custom meta?
- Custom Metabox Info Not Saving
- PHP Warning with Custom Fields
- Problem with multi checkboxes value in metabox?
- Get meta values from parent post and save in child post
- Simple Data picker meta box
- PHP Notice: Unidentified index
- check_admin_referer not working in custom meta box for custom post type
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Order by custom field attribute
- Filter CPT based on meta box value using Flexible Posts widget?
- Select Menu for Custom post Type does not save
- Textarea type on one field custom add_meta_box?
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- loop through custom post-type with two meta_keys
- Extending a CPT by Created by another plugin
- Custom meta box includes
- Creating entries with image attachements within posts and managing them in a list
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Adding a custom “Add Custom Field” button to Custom Meta boxes
- How do I filter a custom post type loop by a field?
- Display div based on Group metabox selection [closed]
- Get custom post fields and display them
- Send email on creation of custom post type and use get_post_meta()
- Just the First Metabox what saves the data!
- How to consume external API from WordPress post editor and display the response data in the custom field?
- custom post type with metabox custom fields