PHP - 使用具有英国日期格式(dd-mm-yy)的strtotime [英] PHP - Using strtotime with a UK date format (dd-mm-yy)

查看:306
本文介绍了PHP - 使用具有英国日期格式(dd-mm-yy)的strtotime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单,在PHP中,我的日期是2011年1月8日,格式为08-01-11 - 当我运行到strtotime并将其转换成不同的日期格式时,它恢复到2011年8月1日 - 不理想!

Quite simply in PHP I have a date of 8th January 2011, in the format 08-01-11 - when I run this into strtotime and convert it back into a different date format, it reverts back to 1st August 2011 - not ideal!

有没有什么简单的方法可以解决这个问题,而不是将所有内容放在不同的数组/变量中,然后再回来?

Is there any easy way around this, rather than having to place everything into different arrays/variables and back again?

谢谢!

推荐答案

strtotime() a href =http://www.php.net/manual/en/function.strtotime.php =noreferrer>仅适用于美国的日期:

strtotime() works with US dates only:


该函数希望给出一个包含美国英文日期格式的字符串,并尝试将该格式解析为Unix时间戳记。

The function expects to be given a string containing a US English date format and will try to parse that format into a Unix timestamp...

您必须重新排列日期格式,或使用 date_parse_from_format() (PHP 5.3+)解析英国tyle string。

You would have to either rearrange the date format, or use date_parse_from_format() (PHP 5.3+) to parse the UK style string.

这篇关于PHP - 使用具有英国日期格式(dd-mm-yy)的strtotime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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