正确输入strtotime [英] Correct input values of strtotime

查看:106
本文介绍了正确输入strtotime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过以下语句转换日期

I want to convert a date by the following statement

$date=date('d M Y, H:m',strtotime($date));

当我尝试$ date的各种值时,它打印出09 Sep 2012, 11:09:

It printed out 09 Sep 2012, 11:09 when I tried various values of $date:

11:00 AM Sunday, 09 Sep 2012
Sunday 09 Sep 2012, 11:00 AM
09 Sep 2012 11:00 AM

strtotime()函数需要什么日期格式?在我看来,其中至少有一个符合英语文本日期时间描述"条件.

What date format does the strtotime() function need? It seems to me at least one of them meets the "English textual datetime description" condition.

推荐答案

看起来唯一的方法是用正则表达式对元素进行正确排序,然后用相应的数字替换月份名称.这样的字符串strtotime将管理. 注意:我说的是PHP 5.2x

Looks like the only way to go is to sort the elements in proper order by regular expressions and then replace the month name by corresponding number. Such a string strtotime will manage. Note: I'm talking about PHP 5.2x

我找到了原因,为什么strtotime不起作用"是因为我在日期格式字符串中打了一个错字,应该有'd M Y,H:i'

I found the reason, why strtotime "wasn't working" was that I made a typo in the date formating string, there should be 'd M Y, H:i'

这篇关于正确输入strtotime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆