php.js : localtime() function

Description

The localtime() function returns the localtime as an associative array if is_associative parameter is set to 1 other wise returns regular array.

Version

1103.1210

Syntax

localtime(timestamp, is_associative)

Parameters

Name Description Required/ Optional Type
timestamp The timestamp parameter is an 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

Practice php.js localtime() function with online editor

Download phpjs.zip

Please Google+, Like this tutorial on FaceBook, Tweet, save it as bookmark and subscribe with our Feed. Have suggestions? comment using Disqus down this page. Thanks.


share with delicious share with facebook w3r rss  share with digg share with reddit share with stumbleupon share with twitter