Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any alternative for date_parse function for php 5.1.*?

Tags:

php

I have to use php function date_parse but it is supported for 5.2.. So is there any alternative for function date_parse for php 5.1..

like image 917
user75472 Avatar asked May 21 '09 06:05

user75472


2 Answers

strtotime, possibly combined with getdate, localtime or gmtime

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

strtotime takes a string, and converts it into a unix timestamp, and the other three functions convert a unix timestamp into an array like date_parse.

like image 172
Stobor Avatar answered Sep 22 '22 04:09

Stobor


Try:

getdate(strtotime($datestr))

Note that some keys are slightly different (eg. 'seconds' rather than 'second' and 'mday' rather than 'day') and getdate doesn't include any error information. getdate also doesn't support fractions of a second.

like image 38
outis Avatar answered Sep 19 '22 04:09

outis