EDIT
You should be using date_create_from_format
or its alias DateTime::createFromFormat()
to convert on format to another. You can try the following
$date = DateTime::createFromFormat('m-d-Y', '03-09-2015');
echo $date->format('d-m-Y');
This will convert 03-09-2015
to 09-03-2015
ORIGINAL ANSWER
This is more a PHP question than WordPress question. You can simply use str_replace
to change the /
in your date to -
. You are not changing the format, so no need for date_format
or any other date related functions
You can try something like
$date="03/09/2015";
$modified_date = str_replace( "https://wordpress.stackexchange.com/", '-', $date );
echo $modified_date;
This will output 03-09-2015
Related Posts:
- Add custom meta box on Post page
- How WordPress autosave can save plugin fields?
- How can I filter the contents of a metafield before it’s displayed in the admin?
- Security checking in meta_box save is reluctant?
- WordPress metaboxes – textfield suggestion automatically populated
- Preset custom fields
- How to pass multiple custom fields as shortcode’s parameters
- Do something with thumbnail image on post publish
- Add custom field for users
- How can i do custom author list?
- How can i force Display names to be the same as Usernames?
- Adding Custom Fields for Img in Posts
- Edit Imported advanced Custom Fields from wordpress Dashboard
- how to display all posts Custom fields dynamically?
- Custom options page checkbox will not save, despite working with text
- Upload files programmatically to users
- How to create Repeater fields using Advanced Custom Fields?
- Admin Dashboard with Custom Tab for Client
- Plugin not saving values when placed in a folder within /wp-content/plugins
- Woocommerce with metabox plugin
- Last modified field for user profile?
- WordPress CMB2 – Run function on save
- dynamically generating plugin syntax
- Carbon Fields use in custom plugin class
- How I can get custom field’s current value?
- UnWanted Custom field added in the wp page edit area
- Woocommerce – How to populate custom select field with stored values on checkout page?
- How to query the custom fields by language?
- Save / Show multi line text in metabox
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- How to toggle between two custom fields in WordPress woocommerce ‘WC Product Field Group’ plugin?
- Retrieving Meta from Image Attachment
- Unable to select image using custom image field type
- Why are my queries interfering with the global post variable?
- How do I enforce users to fill a determined custom field using WyPiekacz?
- Finding the screen id of a page generated with add_menu_page
- Date format – Meta Box plugin
- Adding class to last list item? Not WP generated
- How to Resize the Custom Post Images?
- Amazon.com intergration with WordPress?
- Adding custom meta boxes to specified custom post type
- Access post title from custom meta box on title change
- How can I store data from custom fields to custom tables?
- Woocommerce – Change Variable Product Add to Cart to behave like external product using Custom Field (link) [closed]
- Plugin that lets visitors Like a post (not facebook) and stores likes in custom meta?
- Parent Child Custom Fields with Advanced Custom Fields
- grab or load text on demand
- Dictionary-style definition list plugin
- Advanced Custom Fields Plugin – Images not displaying
- Adding custom Field To The Posts Listing
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- What snippet do I need to type to show my ACF field show up on my theme?
- Is there a way to make [Table Of Content] plugin while not using revision data?
- Table of contents (TOC) plugin is not showing header tag
- Best approach to make all tags searchable by the wordpress search function
- get_post_meta shortcode returns empty field
- Why Custom fields description is not working WordPress Version 5.4.2?
- Adding Custom Endpoint in WordPress Rest API
- General Term for this form Field
- How do I change the functionality of an image slider which is part of ACF?
- How to get checkbox by default true in metabox?
- Make custom post types using ACF
- Problem Advanced Custom Fields PRO
- CMB2 Output Select Box Chosen Option
- Add Cancel Button to a Custom Meta Box
- Custom product page’s style for printing
- If I am not writing a theme, how do I add custom fields to a user for a plugin
- Simple Data picker meta box
- Taxonomy question
- WordPress CPT Url metabox collection
- Add_Meta_box to custom page (formidable edit post)
- why my wordpress dont have toolbar like, plugin, themes and other?
- Create Biographies
- CMB2 Post Search Field displays/repeats initial post if left empty
- WordPress doesn’t save a post revision when changing CMB2 custom fields
- How to add wordpress plugins in along with my standalone theme
- Changing the body of mail sent to new user registration
- Change post template the proper way
- Creating a user ‘add custom field’ section
- Displaying image from a repeatable group
- How to add jquery to my custom post type wp plugin
- What method should I use for a sidebar widget that reads latest posts?
- Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites
- Problem for recover and save metaboxes
- force category table refresh when adding new category
- Is there a way to add a custom input field for every taxonomy term in WP post editor?
- Extending a CPT by Created by another plugin
- get_post_meta does not work
- ACF: Hide a div or template section when a custom field (in a field group) is empty
- How ACF Advanced Custom Field works with Woocommerce Single Product [closed]
- How do I add custom fields to the “Edit page” admin screen?
- Displaying Random Image from ACF Options Page [closed]
- Need help saving input fields for Security Deposit plugin in WC Vendors page
- Adding a variable to a meta field in the backend?
- ACF: Not displaying ACF data from another post
- Order shipped by which driver[hook for woocoomerce order staus changed and popup in admin panel ] [closed]
- Render CMB2 select option to post page [closed]
- Problems with file_exists() with metabox plugin in WordPress
- Is there a plugin or another way that can help me find out the underlying files of a page/post? [closed]
- Meta box not displaying on the plugin page