PHP date_timezone_get() Function6 Jan 2025 | 1 min read This date_timezone-get() function is used to return the time zone of the given DateTime object in the script. SyntaxParameters
Return ValuesThis function returns the DateTimeZone object on success or FALSE on failure. Example 1Output: Indian/Maldives Example 2Output: Pacific/Easter Example 3Output: Europe/Istanbul Next TopicPhp-date-timestamp-set-function |
This function allows the modification in date and time. Syntax date_modify(object,modify); Parameters Parameter Description Required/Optional object Specifies a DateTime object return. Required modify Specifies a date/time string Required Return This function returns NULL on success or FALSE on failure. Example 1 <?php $date=date_create("2018-05-01"); date_modify($date,"+15 days"); echo date_format($date,"Y-m-d"); ?> Output: 2018-05-16 Example 2 <?php $date = new DateTime("2020-12-12"); $date->modify("+10 day"); echo $date->format("Y-m-d"); ?> Output: 2020-12-22 Example 3 <?php ...
1 min read
The PHP microtime() function is used to returns the current Unix timestamp with microseconds. Float value is return by this function. Syntax mixed microtime ([ bool $get_as_float = FALSE ] ) Parameters Parameter Description Required/Optional get_as_float specifies that the function should return a float optional Return This function returns a string in the form "msec sec",...
1 min read
The gettimeofday() function is used to get the current time of the day. It returns a float value. Syntax mixed gettimeofday ([ bool $return_float = FALSE ] ) Parameters Parameter Description Required/Optional return_float Specifies a float value optional Return This function by default returns an array. If return_float is set, this function will return a float. Example...
1 min read
This function returns the default timezone. It is used by all the date and time functions of the PHP. Note : timezone will be returned as a string. Syntax string date_default_timezone_get ( void ) Return This function returns a string. Example 1 <?php echo date_default_timezone_get(); ?> Output: UTC Example 2 <?php ...
1 min read
It returns new date and time. Syntax DateTime date_create ( [$time [, timezone]] ); Note : time and timezone are the optional parameters. Return This function returns the DateTime object on success or FALSE on failure. Example 1 <?php $datefind=date_create("2018-7-25 5:0:00",timezone_open("America/Chicago")); echo date_format($datefind,"Y/m/d H:iP"); ?> Output: 2018/07/25 05:00-05:00 Example 2 <?php $date=date_create("2018-07-27"); ...
1 min read
The gmdate() function is used to changethe GMT/UTC date and time and output is returned in form of data string. It also modifies the date and time format in readable form. Syntax string gmdate ( string $format [, int $timestamp = time() ] ) Parameters Parameter Description Required/Optional Format Specifies the format of...
1 min read
The PHP timezone_version_get() function is used to get the version of the timezone . Syntax string timezone_version_get ( void ) Return This function returns a string. Example <?php echo timezone_version_get(); ?> Output: 0.system TopicJava Methods List ...
1 min read
The date_sub() function is used to subtracts or deduce some formatted data of the date i.e date, month,year, hours,minutes, seconds etc. Syntax date_sub(object,interval); Parameters Parameter Description Required/Optional Object Specifies a DateTime object required Interval Specifies a DateInterval object required Example 1 <?php $date=date_create("2018-07-15"); date_sub($date,date_interval_create_from_date_string("10 days")); echo date_format($date,"Y-m-d"); ?> Output: 2018-07-05 Example 2 <?php $date=date_create("2020-12-15"); date_sub($date,date_interval_create_from_date_string("5 days")); echo date_format($date,"Y-m-d"); ?> Output: 2020-12-10 Example 3 <?php $date = date_create('2018-07-15'); date_sub($date, date_interval_create_from_date_string('5 years')); echo date_format($date, 'Y-m-d') . "\n"; ?> Output: 2013-07-15 Example 4 <?php $date1...
1 min read
The date_time_set() function is used to set the time in a specified format. It returns a datetime object at the end. Syntax date_time_set(object,hour,minute,second); Parameters Parameter Description Required/Optional object Specifies a DateTime object required hour Specifies the hour of the time Specifies the hour of the time minute Specifies the minute of the time required second Specifies the second of the time optional Example 1 <?php $date1=date_create("2018-7-31"); date_time_set($date1,10,24); echo...
1 min read
This function finds out the difference between the two DateTime objects. It represents the difference of days between two dates. Syntax date_diff($datetime1,$datetime2,$absolute); Parameters Parameter Description Required/Optional datetime1 Specifies a DateTime object Required datetime2 Specifies a DateTime object Required absolute Specifies a Boolean value optional Example 1 <?php $date1=date_create("2018-03-1"); $date2=date_create("2018-04-1"); $diff=date_diff($date1,$date2); echo $diff->format("%R%a days"); ?> Output: +31 days Example 2 <?php function dateDiff($start, $end) { $start_t = strtotime($start); $end_t = strtotime($end); $differ = $end_t - $start_t; return...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India