PHP getdate() Function6 Jan 2025 | 1 min read This getdate() function is used to get the information of the current local date/time or the timestamp. SyntaxParameters
ReturnThis function returns an associative array of information related to the timestamp. Example 1Output: Thursday, August 2, 2018 Example 2Output: Array ( [seconds] => 14 [minutes] => 7 [hours] => 7 [mday] => 9 [wday] => 4 [mon] => 8 [year] => 2018 [yday] => 220 [weekday] => Thursday [month] => August [0] => 1533798434 ) Thursday, August 9, 2018 Next TopicPhp-gettimeofday-function |
The PHP timezone_offset_get() function is used to show the offset of the timezone from the GMT. Syntax int timezone_offset_get ( $object, $datetime ); Parameters Parameter Description Required/Optional object Specifies a DateTimeZone object required datetime Specifies a date/time required Return This function returns time zone offset in seconds on success or FALSE on failure. Example 1 <?php $timezone=timezone_open("Asia/Taipei"); $dateTimeOslo=date_create("now",timezone_open("Europe/Oslo")); echo timezone_offset_get($timezone,$dateTimeOslo); ?> Output: 28800 Example 2 <?php $timezone=timezone_open("Africa/Juba "); $dateTimeAmsterdam=date_create("now",timezone_open("Europe/Amsterdam ")); echo...
1 min read
PHP time and date functions informus about current date and time. Time and date can be manipulated by using these functions. 02 Nov - PHP checkdate() Function 02 Nov - PHP date() Function 02 Nov - PHP date_add() Function 02 Nov - PHP date_create() Function 02 Nov - PHP date_date_set()...
2 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 function is used to provide the complete information of a particular date in a specified format and an associative array is returned by it. Syntax date_parse_from_format(format,date); Parameters Parameter Description Required/Optional Format Specifies the format required Date specifies a date required Return This function returns associative array with detailed info about given date. Example 1 <?php print_r(date_parse_from_format("mmddyyyy","05122018")); ?> Output: Array ( [year] => [month] =>...
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 idate() function is used to examine all the different formats of local date and time. Syntax int idate ( string $format [, int $timestamp = time() ] ) Parameters Parameter Description Required/Optional Format Specifies how to return the result required timestamp Specifies a Unix timestamp that represents the date and/or time to be formatted. optional Return This function...
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
If any error comes while parsing the date string, this function will show warnings/ errors in output. Syntax date_get_last_errors(); Example 1 <?php date_create('g$%^jngvnk'); print_r(date_get_last_errors()); ?> Output: Array ( [warning_count] => 1 [warnings] => Array ( ...
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
The date_timestamp_set() function is used to set the date and time based on unix timestamp. It returns a datetime object and unix timestamp represents the date. Syntax date_timestamp_set(object,unixtimestamp); Parameters Parameter Description Required/Optional object Specifies a DateTime object required unixtimestamp Specifies a Unix timestamp representing the date optional Example 1 <?php $date1=date_create(); date_timestamp_set($date1,1533132945); echo date_format($date1,"U = Y-m-d H:i:s"); ?> Output: 1533132945 = 2018-08-01 14:15:45 Example 2 <?php $date=date_create(); date_timestamp_set($date,1533133630); echo date_format($date,"U...
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