English 中文(简体)
PHP: 规定任何格式的日期(特别是:2008-10-20,2008/10/20,2008/10.20, Nov. 20/08)
原标题:PHP: parsing a date of any format (especially: 2008-10-20, 2008/10/20, 2008.10.20, Nov. 20/08)

strtotime ("25/03/1957") 回报不实。 满足所有这些日期的格式? 我们可以想象一下,我们实际上需要多长时间,因此希望你们已经知道。

感谢!

最佳回答

我发现,日落物体支持范围比天线功能更为广泛的形式,而你的服务器的时区环境也发挥了作用;但我最终将建立功能,以取代/使用迄今为止的扼杀方法。 我也证明是有效的,然后试图冲淡表面干 and和毫米(25-03-2001 =>03-25-2001),如果在再次测试之前无效。

问题回答

考虑到某些日期是有效的,但可以指出两个不同的实际日期,任何职能都无法在任何时候“猜测”正确的格式。

To help with that, with PHP >= 5.3, a new function has been added : date_create_from_format -- but it doesn t exist with PHP < 5.3, unfortunately...
(See also DateTime::createFromFormat)


Still, in the example you took, the year 1957 is a possible source of problems : PHP generally works with UNIX Timestamps, when it comes to dates...

而且,至少在32个轨道系统上,those只能代表1970年至2038年之间的日期,因为它们是1970-01年以来第二位数。

为避免这一问题,它常常是使用的良好想法。 日期: <http://fr2.php.net/manual/en/intro.datetime.php” rel=“nofollow noreferer”>引用::

The date and time information is internally stored as an 64-bit number so all imaginable dates (including negative years) are supported. The range is from about 292 billion years in the past to the same in the future.

(将不解决与PHP <有关的 par问题;5.3 ;但解决 date问题......)。





相关问题
Weird Time Issue in Python

Problem with using times in Python. Terminal > Python >>> calendar.timegm(datetime.datetime.now().utctimetuple()) 1258449380 This time indicates GMT: Tue, 17 Nov 2009 09:16:20 GMT Eclipse ...

How does a .NET process get the culture information?

I have a Windows service running (C#, .NET 2.0) on Windows Server 2003 R2. In one server the System.Threading.Thread.CurrentThread.CurrentCulture is {en-AU} and in the other {en-US}. This has caused a ...

Best way to get maximum Date value in java?

I m writing a bit of logic that requires treating null dates as meaning forever in the future (the date in question is an expiration date, which may or may not exist). Instead of putting in special ...

Date format in SQL Server

Short Question: What s the best date format to use in SQL Server? Long Explanation: We re converting our database from mysql to SQL Server. In mysql we always used int(11) to avoid the daylight ...

Converting asp.net/sql web app to be ime zone savy

Our current app stores all dates via the server s datetime. I m thinking we need to update all datetime values in the database over to UTC time. Now for displaying these dates back to the user, I ...

Check if string is of SortableDateTimePattern format

Is there any way I can easily check if a string conforms to the SortableDateTimePattern ("s"), or do I need to write a regular expression? I ve got a form where users can input a copyright date (as a ...

DateTime in PropertyGrid in .Net

I m currently working on some DateTime properties in a PropertyGrid in c#.Net. Im using the default drop-down datetime picker. My question: Is there any way to show the full date with the time? By ...

热门标签