Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Date and Time Functions : date_parse

date_parse

Returns associative array with detailed info about given date (PHP 5 >= 5.1.3)
array date_parse ( string date )

Example 441. A date_parse() example

<?php
print_r
(date_parse("2006-12-12 10:00:00.5"));
?>

The above example will output:

Array
(
   [year] => 2006
   [month] => 12
   [day] => 12
   [hour] => 10
   [minute] => 0
   [second] => 0
   [fraction] => 0.5
   [warning_count] => 0
   [warnings] => Array()
   [error_count] => 0
   [errors] => Array()
   [is_localtime] =>
)

Code Examples / Notes » date_parse

tekmosis

If you're using PHP4 and need similar usage of this function there is getdate() however, getdate() only accepts a timestamp and not a date time; a work around is to use strtotime() in conjunction.
Example usage:
getdate(strtotime('2006-12-12 10:00:00'));
Result:
Array
(
   [seconds] => 0
   [minutes] => 0
   [hours] => 10
   [mday] => 12
   [wday] => 2
   [mon] => 12
   [year] => 2006
   [yday] => 345
   [weekday] => Tuesday
   [month] => December
   [0] => 1165946400
)
Note: This is only helpful if you're looking just for the month, day, year, hour, minute, second values.


gpayne

Careful - date_parse is perfectly happy with something like this:
date_parse("2006-2-31");


Change Language


Follow Navioo On Twitter
checkdate
date_create
date_date_set
date_default_timezone_get
date_default_timezone_set
date_format
date_isodate_set
date_modify
date_offset_get
date_parse
date_sun_info
date_sunrise
date_sunset
date_time_set
date_timezone_get
date_timezone_set
date
getdate
gettimeofday
gmdate
gmmktime
gmstrftime
idate
localtime
microtime
mktime
strftime
strptime
strtotime
time
timezone_abbreviations_list
timezone_identifiers_list
timezone_name_from_abbr
timezone_name_get
timezone_offset_get
timezone_open
timezone_transitions_get
eXTReMe Tracker