w3resource

php.js: idate() function

idate() function

The idate() function is used to get formatted local time/date as integer.

Version:

1103.1210

Syntax:

idate(format, timestamp)

Parameters:

Name Description Required /
Optional
Type
format B - Swatch Beat/Internet Time
d - Day of the month
h - Hour (12-hour format)
H - Hour (24-hour format)
i - Minutes
I - returns 1 when DST is activated otherwise 0
L - returns 1 for leap year otherwise 0
m - Month number
s - Seconds
t - Days in current month
U - Seconds since the Unix Epoch - January 1 1970 00:00:00 UTC
w - Day of the week (0 on Sunday)
W - ISO-8601 numeric week of year, weeks starting on Monday
y - Year
Y - Year in 4 digits
z - Day of the year
Z - Timezone offset in seconds

Optional String
timestamp An integer indicates the unixtimestamp. If a timestamp is not supplied, it gives the current local time. Optional integer

Example of php.js idate() function.  

In the following web document idate() function returns formatted local time/date as integer.

<!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 : idate() function example</title>
<script type="text/javascript" src="../../phpjs/date/datetime.min.js"> </script>
</head>
<body>
<h1 style="color: green">php.js : idate() function example</h1>
<h3>Formatted local time/date as integer.</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
document.write("idate('d')"+'<br />');
document.write(idate('d')+'<br />');
document.write("idate('m')"+'<br />');
document.write(idate('m')+'<br />');
document.write("idate('y')"+'<br />');
document.write(idate('Y')+'<br />');
//]]>
</script>
</body>
</html>

Output of the example:

idate('d')
5
idate('m')
7
idate('y')
2011

View the example of php.js idate() function in the browser

Download phpjs.zip

Previous: php.js : gmstrftime() function
Next: php.js : localtime() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

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://w3resource.com/phpjs/date/idate.php