php.js : localtime() function
localtime() function
The localtime() function returns the localtime as an associative array if is_associative parameter is set to 1 otherwise returns regular array.
Version:
1103.1210
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 - 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 |
Example of php.js localtime() function:
In the following web document localtime() function returns an array.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php.js : localtime() function example</title>
<script type="text/javascript" src="../../phpjs/date/datetime.min.js"> </script>
<script type="text/javascript" src="../../phpjs/variable/variable.min.js"> </script>
</head>
<body>
<h1 style="color: green">php.js : localtime() function example</h1>
<h3>Localtime as an array</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
print_r(localtime());
//]]>
</script>
</body>
</html>
Output of the example:
Array ( [0] => 9 [1] => 52 [2] => 18 [3] => 5 [4] => 6 [5] => 111 [6] => 2 [7] => 185 [8] => 1)
View the example of php.js localtime() function in the browser
Previous: php.js: idate() function
Next:
php.js : microtime() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/phpjs/date/localtime.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics