PHP gmstrftime() Function6 Jan 2025 | 1 min read The gmstrftime() function is used to set the date and time according to the local settings . It formats the GMT/UTC date and time. SyntaxParameters
Return ValuesThis function returns a string which is formatted according to the given format string. If no timestamp is given, this function will return the current local time. Example 1Output: December 12 1998, 10:00:00 GMT 2018. August 09. Thursday. 06:39:32 GMT Example 2Output: December 31 1998, 20:00:00 GMT 2018. August 09. Thursday. 06:42:42 GMT Next TopicPhp-idate-function |
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 PHP timezone_location_get() function is used to show the information of the location of the given timezone. Syntax timezone_location_get(object); Parameters Object: It specifies a DateTimeZone object. Return Returns array on success or FALSE on failure. Example 1 <?php $timezone=timezone_open("Asia/Taipei"); print_r(timezone_location_get($timezone)); ?> Output: Array ( [country_code] => TW [latitude] => 25.05 ...
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 is used to set the date. All the dates are set according to the ISO 8601 standard and that uses weeks and offsets. Syntax date_isodate_set(object,year,week,day); Parameters Parameter Description Required/Optional Object Specifies a DateTime object returned Required year Specifies the year of the date Required week Specifies the week of the date Required day Specifies the offset from the first day...
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 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_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
PHP date_interval_format() for formatting the interval, this function is used in the script. We can also write it as DateInterval::format(). Syntax DateInterval::format(format); Note: Here format is the required string. Return This function returns the formatted interval. Example 1 <?php $date1=date_create("2018-01-01"); $date2=date_create("2018-02-10"); $diff=date_diff($date1,$date2); echo $diff->format("Total number of days: %a."); echo "\n"; echo $diff->format("Total number of days: %R%a."); echo "\n"; echo $diff->format("Month:...
1 min read
This date_timezone-get() function is used to return the time zone of the given DateTime object in the script. Syntax DateTimeZone date_timezone_get ( DateTime $object ) Parameters Parameter Description Required/Optional object Specifies a DateTime object required Return Values This function returns the DateTimeZone object on success or FALSE on failure. Example 1 <?php $date1=date_create(null,timezone_open("Indian/Maldives")); $ind=date_timezone_get($date1); echo timezone_name_get($ind); ?> Output: Indian/Maldives Example 2 <?php $date1=date_create(null,timezone_open("Pacific/Easter")); $paci=date_timezone_get($date1); echo timezone_name_get($paci); ?> Output: Pacific/Easter Example 3 <?php $date1=date_create(null,timezone_open("Europe/Istanbul")); $eu=date_timezone_get($date1); echo timezone_name_get($eu); ?> Output: Europe/Istanbul ...
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
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