PHP localtime() Function6 Jan 2025 | 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. SyntaxParameters
Example 1Output: Array ( [0] => 45 [1] => 50 [2] => 6 [3] => 9 [4] => 7 [5] => 118 [6] => 4 [7] => 220 [8] => 0 ) Array ( [tm_sec] => 45 [tm_min] => 50 [tm_hour] => 6 [tm_mday] => 9 [tm_mon] => 7 [tm_year] => 118 [tm_wday] => 4 [tm_yday] => 220 [tm_isdst] => 0 ) Example 2Output: Array ( [0] => 26 [1] => 54 [2] => 6 [3] => 9 [4] => 7 [5] => 118 [6] => 4 [7] => 220 [8] => 0 ) Array ( [tm_sec] => 26 [tm_min] => 54 [tm_hour] => 6 [tm_mday] => 9 [tm_mon] => 7 [tm_year] => 118 [tm_wday] => 4 [tm_yday] => 220 [tm_isdst] => 0 ) Next TopicPhp-microtime-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 strftime() function is used to set the date and time according to the local settings . It formats the GMT/UTC date and time. Syntax string strftime ( string $format [, int $timestamp = time() ] ) Parameters Parameter Description Required/Optional Format Specifies how to return the result required Timestamp Specifies a Unix timestamp optional Return This function returns...
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
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
The gmstrftime() function is used to set the date and time according to the local settings . It formats the GMT/UTC date and time. Syntax string gmstrftime ( 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...
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
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
This date function work same as date_parse_from_format() that provides the complete information about the particular date in an specified format and return data in form of array. Syntax array date_parse ( string $date ) Parameters Parameter Description Required/Optional date Specifies a date Required Return This function returns array with information about the parsed date on success...
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
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