PHP: localtime() function
Description
The localtime() function is used to get the localtime.
Version:
(PHP 4 and above)
Syntax:
localtime(timestamp, is_associative)
Parameters:
Name | Description | Required/ Optional | Type |
---|---|---|---|
timestamp | The timestamp parameter is a Unix timestamp.If no timestamp is specified, it uses the current local time. | Optional | Integer |
is_associative | If the argument is set to true the array returned an
indexed array otherwise the array returned is an
associative array. The following list describes the elements of the returned array. tm_sec - seconds tm_min - minutes tm_hour - hour tm_mday - the day of the month. "tm_mon" - month of the year, starting with 0 for January "tm_year" - Years since 1900 "tm_wday" - Day of the week "tm_yday" - Day of the year "tm_isdst" - Is daylight savings time in effect |
Optional | Boolean |
Return value:
An array.
Value Type: Array.
Example:
<?php
print_r(localtime(time(),true));
echo '<br />';
print_r(localtime());
?>
Sample Output:
Array ( [tm_sec] => 52 [tm_min] => 20 [tm_hour] => 7 [tm_mday] => 19 [tm_mon] => 0 [tm_year] => 111 [tm_wday] => 3 [tm_yday] => 18 [tm_isdst] => 0 ) Array ( [0] => 52 [1] => 20 [2] => 7 [3] => 19 [4] => 0 [5] => 111 [6] => 3 [7] => 18 [8] => 0 )
View the example in the browser
See also
PHP: Tips of the Day
PHP: Anonymous recursive PHP functions
In order for it to work, you need to pass $factorial as a reference
$factorial = function( $n ) use ( &$factorial ) { if( $n == 1 ) return 1; return $factorial( $n - 1 ) * $n; }; print $factorial( 5 );
Ref : https://bit.ly/38dj7jm
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework