PHP date_timezone_set() Function6 Jan 2025 | 1 min read This date_timezone_set() function is used to set the time zone for the DateTime object. SyntaxParameters
Return ValuesThis function returns NULL on success or FALSE on failure. Example 1Output: 2018-07-25 00:00:00+05:00 2018-07-25 00:00:00+05:00 Example 2Output: 2018-07-25 00:00:00+02:00 2018-07-25 03:00:00+05:00 Example 3Output: 2018-07-25 00:00:00+02:00 2018-07-25 03:00:00+05:00 2018-07-25 08:00:00+10:00 Next TopicPhp-get-date-function |
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 gmmktime() function is used to find the day of that particular date. It returns the returns the Unix timestamp for a GMT date. Syntax int gmmktime(hour,minute,second,month,day,year,is_dst); Parameters Parameter Description Required/Optional Hour Specifies the hour optional Minute Specifies the minute optional Second Specifies the second optional Month Specifies the month optional Day Specifies the day optional Year Specifies the year optional Is_dst specifies a GMT date optional Return This function returns an integer Unix...
1 min read
This PHP timezone_open() function is used to return the name of the timezone and also create a new DateTimeZone object. Syntax timezone_open ( $timezone ) Parameters timezone: It specifies a timezone. Return This function returns the DateTimeZone object on success or FALSE on failure. Example 1 <?php $timezone=timezone_open("Europe/Paris"); echo timezone_name_get($timezone); ?> Output: Europe/Paris Example 2 <?php $timezone=timezone_open("Europe/Oslo"); echo timezone_name_get($timezone); ?> Output: Europe/Oslo TopicPhp-timezone-version-get-function ...
1 min read
This function clears the date and year exit or not. Syntax bool checkdate ( int $month , int $day , int $year ) Parameters Parameter Description month The month is between 1 and 12 inclusive. day The day is within the allowed number of days for the given month. year The year is between 1 and...
1 min read
This PHP timezone_abbreviations_list() function is used to return an associative array that contains the timezone name, offset and the dst. Syntax array timezone_abbreviations_list(); Return This function returns array on success or FALSE on failure. Example 1 <?php $timezone_abbreviations = timezone_abbreviations_list (); print_r($timezone_abbreviations["acst"]); echo "----------------------------------------------\n"; # Using...
9 min read
It is used to set a new date and formatting of date is also allowed. It returns a datetime object. Syntax void date_date_set ( DateTime $object, int $year, int $month, int $day ); Parameters Parameter Description object Required. Specifies a DateTime object returned year Required. Specifies the year of the date month Required. Specifies the month...
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 PHP localtime() function is used to print the time in the form of indexed and associative array. It returns the local time. Syntax localtime(timestamp,is_assoc); Parameters Parameter Description Required/Optional timestamp Specifies a Unix timestamp optional Is_assoc Specifies whether to return an associative array or indexed array. optional Example 1 <?php print_r(localtime()); echo "<br><br>"; print_r(localtime(time(),true)); ?> Output: Array ( [0] => 45 ...
2 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
This function sets the default timezone. It is used by all the date and time functions of the PHP. Syntax bool date_default_timezone_set ( string $timezone_identifier ) Parameters timezone_identifier: The timezone identifier like UTC or Europe/Lisbon. The list of valid identifiers is available in the List of Supported Timezones. Return This function...
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