there is a custom function in wordpress called date_i18n. so basically you do
echo date_i18n( 'H:i d-m-Y', $ts );
without the setLocale stuff..
find the function date_i18n and its parameters here.
you could even build in your translation all in there, without the language check before:
date_i18n( __( 'H:i d-m-Y', 'textdomain' ) );
(replace ‘textdomain’ with your theme textdomain..)
Related Posts:
- How to get User Time Zone in WordPress?
- Can’t add to time? [closed]
- WordPress returns a wrong date
- Unable to set right time in admin and frontend template
- Get date numerical and separate?
- Print last modified date only on posts
- 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
- Adding a number to a date
- Display Year and Month from custom field + Age Calculator
- Convert custom field date format to “WordPress default”
- Calculate business days
- How to get WordPress Time Zone setting?
- the_date() not working
- Converting timestamps to local time with date_l18n()
- PHP function showing wrong time in WordPress
- Converting Unix timestamp to wordpress date
- Date, Time, and Timezones
- How to get year, month and hour in WordPress?
- Archive listing of posts by publish year (multiple years)
- Why does this echo values in the wrong order?
- How to check for WordPress timezone type?
- WP_Query meta_query results date by date
- Convert a date to ISO8601 date format
- wrong php date()?
- Way to display “Yesterday”, “Today”
- Customize Time Stamp
- Displaying the Month and Year that a page was Created?
- Adding number to date not working [closed]
- Set meta field to publish date + 2 weeks
- How to manually change current date to post date in frontend?
- Convert WordPress date format to jQuery UI Datepicker format
- Converting Y-m-d to a date with a Month name? [closed]
- Find hours between post_date and post_date_gmt
- 3 different times on my WordPress website
- How would I use this filter to change the output of the date format to “Twitter time”?
- Check If Post Was Published More Than 6 Months Ago Using get_the_date
- How do I check or test a WordPress Auto Year Change Script?
- Function Reference/human time diff for future posts
- Shortcode function doesnt work without caption
- Using php inside javascript [closed]
- Comparing Dates from custom field
- How to get movies by date
- PHP time function ($today) for GMT +1
- Is there way to toggle the publish date display?
- Hide publish date when update date
- How to detect and handle the time difference between server and user in WordPress?
- Issue in displaying the ongoing event and current events in the post
- current_time function incorrect in plugin and PHP, not in WordPress admin
- No more get_option(‘date_time’) in WordPress 5.5?
- Time Stamp In A WordPress Post Title That Does Not Keep Refreshing
- Learndash: Customize user enroll time
- Don’t update modified post date when user add a product review or comment?
- Possible to edit custom date field and display?
- Get posts from year from URL
- Changing Date Format on Custom Meta Data w/shortcode call
- Count time from registration date to today
- Update existing post times to random times?
- Primary navigation menu with timed items from custom post type
- How to pull date/time in french format for wordpress post?
- Timezone for Plugin
- How to get Unix Local Time?
- Grouping posts by date
- WordPress change post date format from english to japanese
- Ordering / grouping posts by datepicker ACF
- Comparing Dates within plugin using PHP If statement
- Array sorting assistance
- How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp
- Can i show items based on the day with php?
- Get system timestamp in wordpress
- Display Current Time using shortcode
- How do I convert a custom field to a php date format? [closed]
- Change date/time format in custom plugin
- Fatal error: Call to undefined function mysql_connect()
- How can I run a .php file located in my site’s root folder?
- Use template for posts with a particular category grandparent
- How to start a script from cli within wordpress
- Missing sidebar parameter “fix” – before_content
- Move category description below post list in blog
- Pagination for custom shop loop woocommerce
- wp ajax return 0
- How to use theme function in post/page?
- Custom Registration username_exists / email_exists
- WordPress language switcher doesn’t work
- Search.php gets metadata from first post
- WordPress Multisite login_redirect to primary blog and specific page based on role
- Pagination at category doesnt work with same name of page
- Is it secure to use SMTP password in .php file in WordPress website?
- wp_signon works local, not on https
- How to have more than one ID included in the exclude command?
- Search for images that width and height is more than 500
- I need help implement a Javascript code into the PHP file
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- if is_home(), change class of menu-item-225 of wp_nav_menu
- WordPress most commented posts of last X days
- How to check if a value exists in one of two database tables
- How to use multiple 404 Error Pages in WordPress
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin