PHP gmdate() Function6 Jan 2025 | 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. SyntaxParameters
ReturnIt returns a formatted date string. If timestamp is using a non-numeric value, FALSE is returned and an E_WARNING level error is emitted. Example 1Note: here?l? is the full textual representation of a dayOutput: Friday Example 2Output: Friday 3rd of August 2018 04:56:05 PM Example 3Output: Aug 3, 2000 was on a Thursday Example 4Output: Fri, 03 Aug 18 17:06:58 +0000 1975-10-03T00:00:00+00:00 Next TopicPhp-gmmktime-function |
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
This function is used to return date in a specified formati.e format of year ,month and day . Syntax string date_format ( DateTime $object, string $format ) Parameters Parameter Description Required/Optional object Specifies Datetime object required format Specifies the format for the date required Return This function returns formatted date on success or FALSE on failure. Example 1 <?php $date=date_create("2018-03-15"); echo date_format($date,"Y/m/d H:i:s"); ?> Output: 2018/03/15...
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
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
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 date_timezone_set() function is used to set the time zone for the DateTime object. Syntax void date_timezone_set ( DateTime $object, DateTimeZone $timezone ) Parameters Parameter Description Required/Optional object Specifies a DateTime object required timezone Specifies a DateTimeZone object required Return Values This function returns NULL on success or FALSE on failure. Example 1 <?php $date=date_create("2018-07-25",timezone_open("Indian/Kerguelen")); echo date_format($date,"Y-m-d H:i:sP") . "\n"; date_timezone_set($date,timezone_open("Indian/Maldives")); echo date_format($date,"Y-m-d H:i:sP"); ?> Output: 2018-07-25 00:00:00+05:00 2018-07-25...
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 date_sunset() function is used to get the timing of sunset of a particular day and location. This function returns the sunset time of different locations. Syntax mixed date_sunset ( int $timestamp [, int $format = SUNFUNCS_RET_STRING [, float $latitude = ini_get("date.default_latitude") [, float $longitude = ini_get("date.default_longitude")...
1 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
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