As mmm said, wp stores all dates× in gmt, but will show times as per the setting timezone. So you can cgange the timezone without the history needing to be updated.
I prefer to use the php datetime when working with time. Gives better control and flexibility, eg if you want to show events in different users timezones, let the system deal with daylight saving etc.
To Fetch the wp timezone and create tz object, then use
$tzs = get_option('timezone_string');
$tzobj = timezone_open($tzs);
To create datetime object for ‘now’ in a particular timezone
$now = date_create('now',$tzobj );
to format dates & times, use any format accepted by date()
echo date_format($now, 'Y-m-d H:i:s');
Related Posts:
- 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
- How to get User Time Zone in WordPress?
- 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
- 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
- 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”
- 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?
- Shortcode function doesnt work without caption
- Using php inside javascript [closed]
- Comparing Dates from custom field
- 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
- No more get_option(‘date_time’) in WordPress 5.5?
- 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
- Primary navigation menu with timed items from custom post type
- How to pull date/time in french format for wordpress post?
- 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
- Can i show items based on the day with php?
- 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
- Allow Editors to edit pending posts but not draft ones
- How Attackers write script into my php files?
- Need help on WordPress and php
- Looking to exclude blog posts from category Previous/Next buttons
- WordPress Customizer not setting default value upon initial install?
- there’s a way to include a minimal WP for check only the current user, its roles (caps?) and then release/free it?
- Does WordPress have a built in reference to the PHP version its running under? [closed]
- Blank space at beginning of tag?
- Update PHP version 5.3 to 7.2 or first WP 4.7.11 to 4.9.8?
- How to display conditional-content if wp_nav_menu( $args ) retruns something
- Make the first item as default on Woocommerce product category items list
- Get first URL from post content
- Setting custom canonical urls
- WordPress blog post url on category page
- PDF file randomly breaks upon upload
- dividing sub-categories by parent category – WordPress
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Remove author link wherever author’s name is display
- How set a custom URL for a new theme file in WP?
- file_get_contents(includes_url( ‘/js/jquery/jquery.js’ )); not working
- what is the method to echo class attribute inside the i tag? [closed]
- PHP Warning: include(): Unable to allocate memory for pool
- Can’t change website Title on wordpress
- Set cookie for visitor
- Is there a way to create a “copy post” link?
- add role on WordPress in PHP on a second database
- Enqueue assets from multiple directories using add_action/do_action
- How to redirect (301) trashed post to it’s parent taxonomy TERM ARCHIVE instead of 404 page
- A WordPress Page to display custom database query results
- How to detect and make links nofollow in author description
- Change taxonomy for categories
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- How to echo a different field if another field is empty?
- Remove the_content From Loop
- Display Sale Price Before Regular Price (WooCommerce)
- Load a Header in wordpress
- Using is home to get content [closed]
- Find owner of coupon
- WordPress wp_remote_request() – How to do async await in wordpress php?
- How Create Automatically Image jpg.webp from image .jpg without delete or change original images upload