Share on Google+Share on Google+

getdate()

Advertisement
Form this following example, you will learn to access the information of the Unix timestamp.

PHP getdate() Function

The PHP getdate() function returns an array containing the date information of Unix timestamp, or the current local time. 

Syntax of getdate() function in PHP

getdate(timestamp)

Parameter  of getdate() function in PHP

timestamp - The optional timestamp parameter is an integer Unix timestamp that defaults to the current local time if a timestamp is not given. In other words, it defaults to the value of time(). 

Return Value

The returning array contains ten elements with relevant information needed when formatting a date string:

seconds - The  numeric representation of seconds - It returns 0 to 59
minutes - The  numeric representation of minutes - It returns 0 to 59
hours - The  numeric representation of hours - It returns 0 to 23
mday - The numeric representation of day of the month - It returns 1 to 31.
wday - The  numeric representation of day of the week - It returns 0 (for Sunday)  to 6 (for Saturday)
year - A full numeric representation of year in four digits like 1998, 2009
yday - The  numeric representation of day of the year - It returns 0 through 365
weekday - A full textual representation of name of the week - Sunday through Saturday
month - A full textual representation of name of the month like January or March 
0 Seconds since the Unix Epoch, similar to the values returned by time() and used by date() - System Dependent, typically -2147483648 through 2147483647. 

Example of getdate() function in PHP:

<?php
print_r(getdate());
?>

Output:

Array
(
[seconds] => 24
[minutes] => 32
[hours] => 21
[mday] => 12
[wday] => 3
[mon] => 1
[year] => 2009
[yday] => 26
[weekday] => Thursday
[month] => August
[0] => 1076511381

Advertisements

Advertisement

Posted on: August 27, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.