PHP的strtotime()与另一年的日期混乱 [英] php strtotime() messes with date of a different year

查看:103
本文介绍了PHP的strtotime()与另一年的日期混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用php重新格式化日期并将其发布到mysql.一切顺利,直到我过了明年的日期.例如,Mon, 14 Jan, 2013将被翻译为2012-01-16.格式是正确的,但不是日期,我什至尝试更改通过的格式,但仍然没有更改.这是它得到Mon, 14 Jan, 2013的东西,这是处理它的php:

I am using php to reformat a date and post it to mysql. Everything works great until I pass dates for next year. For example Mon, 14 Jan, 2013 will be translated into 2012-01-16. The format is correct just not the date, I have even tried changing the format I pass it, still no change. Here is what it gets Mon, 14 Jan, 2013 and here is the php that processes it:

$startdate = $_REQUEST['one'];
$start = date("Y-m-d", strtotime($startdate));

为什么只有在我们进入新的一年甚至过去的几年时才会发生打ic的任何线索?

any clues as to why the hiccup happens only when we enter a new year, even past years?

推荐答案

看看

Have a look here for the list of all valid formats for strtotime(). The one you're using is not present.

如果要改用date_create_from_format,请按以下步骤操作:

If you want to use date_create_from_format instead, here's how:

date_create_from_format("D, d M, Y", "Mon, 14 Jan, 2013")

这篇关于PHP的strtotime()与另一年的日期混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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