문제

Hi I have a few dates coming in random formats:

    Wed, 16 Mar 2011 15:27:48 +0000

or

2011-03-16T17:42:05+0000

and I need to be able to convert them into Unix time in PHP. I assume I need to use mktime() , ,but how do I format my mktime ? I'm having trouble understanding the examples in the manual :/

Thanks

도움이 되었습니까?

해결책

strtotime() can work, but if the dates you're passing in are ambiguous (what is 01/02/03? Feb 1st, '03? Mar 2 '01?) it'll turn around and chew you a new one.

Safest option is to use date_create_from_format(), which lets you specify an explicit format for the input.

다른 팁

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top