Is there an alternative to the date_parse function for php 5.1. *?

I need to use the php date_parse function, but it is supported for 5.2 .. So is there an alternative for the date_parse function for php 5.1 ..

+6
php
source share
4 answers

strtotime , possibly combined with getdate , localtime or gmtime

getdate(strtotime("20 Jan 2009")); 

strtotime takes a string and converts it to a unix timestamp, and the other three functions convert the unix timestamp to an array, such as date_parse.

+6
source share

Try:

 getdate(strtotime($datestr)) 

Note that some keys are slightly different (for example, β€œseconds” rather than β€œsecond” and β€œday” rather than β€œday”), and getdate does not contain any error information. getdate also does not support fractions of a second.

+1
source share

I don't know what you mean by alternative, but check this:

php.net getdate ()

Tip: look to the left, you will see related functions.

0
source share

Just wondering why?

strtotime () seems to be the closest answer. Use timestamps (see Time (), mktime (), etc.) to avoid such parsing of strings.

0
source share

All Articles