Strtotime with European date format

后端 未结 5 2220
小蘑菇
小蘑菇 2021-01-06 22:02

I\'m trying to use strtotime to convert the following date:

07/09/2009 17:01:27

It\'s the Europe/London timezone format for 7th of September

The func

5条回答
  •  醉酒成梦
    2021-01-06 22:40

    Providing you're not on Windows you can use strptime instead, and explicitly set the format. As OIS points out, strptime isn't available on Windows.

    To convert from the split up year/month/day etc values to a unix timestamp you can pass them into mktime. Slightly fiddly, but it works.

    One reason you might want to do this would be to print it in a different format using date.

    From the strptime php.net page:

    Example #1 strptime() example

    
    

    The above example will output something similar to:

    03/10/2004 15:54:19

    Array
    (
        [tm_sec] => 19
        [tm_min] => 54
        [tm_hour] => 15
        [tm_mday] => 3
        [tm_mon] => 9
        [tm_year] => 104
        [tm_wday] => 0
        [tm_yday] => 276
        [unparsed] =>
    )
    

提交回复
热议问题