Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
m/d/y 或 dmy 格式的日期通过查看各个组件之间的分隔符来消除歧义:如果分隔符是斜杠 (/),则假定为美式 m/d/y;而如果分隔符是破折号 (-) 或点 (.),则假定为欧洲 dmy 格式。
我需要从格式中获取 unixtimestampMM-DD-YYYY HH:MM:SS 根据 php.net 文档,如果日期分隔符是破折号 (-),则DD-MM-YYYY假定格式返回无效的时间戳。
MM-DD-YYYY HH:MM:SS
DD-MM-YYYY
strtotime()PHP 5.2x 或任何其他解决方法是否有替代方法?
strtotime()
用斜杠替换破折号:
strtotime(str_replace('-', '/', "08-10-2012 09:54:00"));