I don’t see a function to do what you want directly, but it is not hard to retrieve the format that WordPress has configured:
$df = get_option('date_format');
$tf = get_option('time_format');
You can then substitute $df
wherever you had a hard-coded date format (or $tf
for a time format). In your example, that would look like this:
$timestamp = strtotime($content);
$df = get_option('date_format');
$hol_date = sprintf(
'<time datetime="%1$s">%2$s</time>',
date('c', $timestamp),
date($df, $timestamp) );
Related Posts:
- WordPress returns a wrong date
- Unable to set right time in admin and frontend template
- display month in french in wordpress/php?
- Get date numerical and separate?
- Print last modified date only on posts
- Adding number to date not working [closed]
- How to get User Time Zone in WordPress?
- Comparing Dates from custom field
- Get date function not working
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- WordPress wrong dates bug
- Can’t add to time? [closed]
- Adding a number to a date
- Display Year and Month from custom field + Age Calculator
- PHP function showing wrong time in WordPress
- How to handle a custom form in wordpress to submit to another page?
- How to get year, month and hour in WordPress?
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- How to use multiple query with same meta key
- How can i create a function to get youtube video time
- Getting movie and serial on actor page
- Match checkbox data with page title to show certain items
- Geocoding an Exploded Custom Field Array
- Removing WordPress profile fields from non-admins
- Use ajax to update_post_meta
- WooCommerce: update custom fields after checkout validation failure
- If Meta Checkbox is checked, do something?
- Show custom field if it exists, and show different elements if it doesn’t
- Custom field value not saving when it contains a URL?
- tracking number field in Woocommerce order [closed]
- Displaying the Month and Year that a page was Created?
- Sort posts by custom fields value using dropdown menu
- Need Help Fixing My Iframes [closed]
- How can I add extra word in permalink when someone click download button?
- how to retrieve a value if a checkbox is checked
- Trouble checking if custom woocommerce checkout field is empty or not
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Add / Update Custom Fields After Select Pictures in Media Window
- conditional logic for front-end custom field edits
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Which PHP page is the Default Posts Page
- Remove the last X characters of a custom field value
- Non-Closing PHP Query in WordPress Loop
- Converting Y-m-d to a date with a Month name? [closed]
- Find a way to retrive data updated through metabox plugin to web page
- Why are the details of my todo not saving?
- Can’t save php string to a custom field
- How to show/hide php table rows based on the content of custom fields
- How would I use this filter to change the output of the date format to “Twitter time”?
- how to get serialized post meta
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- Handling repeater data
- How to add data to a custom field at the wp_users table?
- Shortcode function doesnt work without caption
- Conditional featured image with youtube thumbnail
- Add a counter for mouseovers (custom field)
- Including Custom fields within the_content
- How can i make a search box to search by custom field
- Show field if it has contents on Advanced Custom Fields
- the_meta – no get_the_meta query?
- Display Custom Field in Sidebar if Value is Present
- Using a string from a custom field within a link
- PHP time function ($today) for GMT +1
- Make separate text boxes for separate WordPress Custom Fields
- Dynamically added custom fields not displayed on WooCommerce email notifications
- Hide publish date when update date
- How can I add diffrent editable text fields?
- How to detect and handle the time difference between server and user in WordPress?
- Display custom field value in woocommerce variable product via jQurey
- Include custom fields in search
- update_term_meta() only updating once on certain meta keys
- Issue in displaying the ongoing event and current events in the post
- Query on a repeater date (acf)
- Generating 3 random numbers and saving them in database
- ACF – Can’t get custom post type by taxonomy
- Sum All the Post Meta of Published posts of Current Logged in user
- When working with a post, almost all wp_postmeta are deleted
- What syntax is this? “{{post.price}}”
- Ordering / grouping posts by datepicker ACF
- How to use something like meta_query but for fields?
- Comparing Dates within plugin using PHP If statement
- Array sorting assistance
- php if, else & custom fields – syntax error
- How to get the first letter from custom field?
- Meta box not saving spaces
- custom field meta-box with dropdown/autocomplete
- If Elseif Query
- Display selected parts from selected pages on the frontpage?
- Display custom meta box in my template file
- Too many if’s and else if’s ?? – Must be better way [closed]
- How do I convert a custom field to a php date format? [closed]
- Advanced Custom Fields Show PHP in Text Areas
- WP query with variables gives no result for specific user
- Change date/time format in custom plugin
- Displaying custom meta box value in a custom post page
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- How to execute a shortcode within a custom field?