PHP wordpress get timezone Example – MySQL

Today, We want to share with you PHP wordpress get timezone.In this post we will show you wordpress get website time, hear for wordpress strtotime timezone we will give you demo and example for implement.In this post, we will learn about How to get WordPress Time Zone setting? with an example.

PHP wordpress get timezone

There are the Following The simple About Set correct timezone in PHP Date function Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to get current date and time in WordPress?, so the Get GMT Offset from ‘gmt_offset’ option in wordpress is used for this example is following below.

How to get WordPress Time Zone setting?

Get gmt_offset

<?php echo get_option('gmt_offset'); ?>

Get timezone_string

<?php echo get_option('timezone_string'); ?>

How to get date using timezone saved in options?

  How TO Check if checkbox is checked with jQuery?

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

$timezone_string = get_option('timezone_string');

wordpress – current timezone using php

    if (date_default_timezone_get()) {
        echo 'Your Current Time in  ' . date_default_timezone_get() . ':';

wp timezone and gmt offset

function set_defaults_for_datetime() { 
	if (($timezone_str = get_option ('timezone_string') ) and (!empty($timezone_str))) {
			$fulltimezone = timezone_open($timezone_str);
	else {	
		if (($gmt_offset = get_option ('gmt_offset')) and (!(is_null($gmt_offset))) and (is_numeric($gmt_offset))) {
			$timezone_str = $this->fetch_offset_from_zone($gmt_offset);
			$fulltimezone = timezone_open($timezone_str );
		else {
			$fulltimezone = timezone_open(date_default_timezone_get()); // this will give UTC as wordpress  ALWAYS uses UTC
	return $fulltimezone;
function fetch_offset_from_zone($offset) {

	$timezones_list = calc_offset_from_tz_list ();	

	$timezones_list = array(
		'8:30' => 'Asia/Harbin',
		'8:45' => 'Australia/Eucla',
		'10:30' => 'Australia/Lord_Howe',
		'12:45' => 'Pacific/Chatham',
		'13:45' => 'Pacific/Chatham',

	$intoffset = intval($offset);
	$stroffset = strval($intoffset);
	if (isset($timezones_list[$stroffset])) 
		return ($timezones_list[$stroffset]);
		return false;
function calc_offset_from_tz_list () {
	$list_time_zone = timezone_identifiers_list();
	//echo '<pre>'.print_r($list_time_zone, true).'</pre>';
	$utc = new DateTimeZone('UTC');
	$now = new DateTime("now", $utc);
	foreach ($list_time_zone as $fulltimezone) {
		$allObject = new DateTimeZone($fulltimezone);
		$off = $allObject->getOffset($now)/(60*60); 
		$hour = (int) $off;
		$decimal = $off - $hour; 
		$floarhour = $decimal * 60;
		$offsets[$fulltimezone] = (string) $hour ;
		if ($floarhour > 0) $offsets[$fulltimezone] .= ':'. (string) $floarhour  ;
	//echo '<pre>'.print_r( $offsets, true).'</pre>';
	$dtaa_timeZonePrt =array_flip($offsets);
	echo '<pre>'.print_r( $dtaa_timeZonePrt, true).'</pre>';
	return $dtaa_timeZonePrt;

Get TimeZone Offset From UTC


Web Programming Tutorials Example with Demo

Read :

  How to get CSS class Name Property using Jquery


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about wordpress get mysql date.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   VueJS Global Constants Set and Get Variables
  2.   PHP Yii Maintenance Mode Tutorial with Examples
  3.   Codeigniter drag and drop files Multiple Images Upload
  4.   PHP Laravel 5 Class Form HTML not found Resolve Error
  5.   set operations sql
  6.   Laravel Display Decoded JSON From Database in Blade View
  7.   Angularjs multiple Check and uncheck all checkbox
  8.   Laravel eloquent join with condition
  9.   PHP Laravel 5 Class Form HTML not found Resolve Error
  10.   How to get CSS class Name Property using Jquery

Leave a Reply

Your email address will not be published. Required fields are marked *