Test Valid Date String for JavaScript

发表日子 2013-05-31 20:44:00
最后修正 2023-11-22 15:29:06

Here we check the valid strings for the argument of the Date:: class constructor to create Date object under JavaScript, ie,
<script type="text/javascript">
var objDate;
objDate = new Date("May 02, 2026 21:37:33 GMT+0200");
<script>
We are trying to get the PHP date format string to format date time to form the pipeline PHP DateTime() => js Date() => document.write() to output on screen. Here is the summary of cases we tested for you:
#js new Date() FeedIEChromeFirefoxSafariOperaMobile
0May 02, 2026 21:37:33 GMT+0200++++++
1May 02 2026 21:37:33 GMT+0200++++++
2May 02, 2026 21:37:33 GMT+2++++++
32026-05-02 21:37:33 GMT+0200-+--++
42026-05-02 21:37:33 GMT+02:00-+--++
52026-05-02 21:37:33 GMT+200-+--++
602 May 2026 21:37:33+02:00-+----
7May 02 2026 21:37:33 GMT+2:00-++-++
8May 02, 2026 21:37:33 GMT+02:00-++-++
92026-05-02 21:37:33 GMT+2-+--++
102026-05-02 21:37:33-+--++
112026-05-02T21:37:33+02:00+++++-
122026-05-02 21:37:33+02:00-+----
1305-02-2026 21:37:33 GMT+0200++---+
1405/02, 2026 21:37:33 GMT+0200+++-++
1502-May-2026 21:37:33 GMT+0200-+-+-+
Tab. I: + Valid Date Time String for Javascript::Date() class, - Invalid.

JavaScript is very English speaking. In effect, among the 3 first universal formats, the English month abbreviation is used. As it can be observed that no pure numerical date string is found like "2026-05-02 21:37:33" to fit JavaScript syntax in all browsers. Please check this with your preferred browser.

Detail of JavaScript Tests

Below, the bold date time outputs at the right hand side of => are the JavaScript Date Class results.

0. Good Format "mmm dd, yyyy hh:mm:ss GMT+0200"

For example, May 02, 2026 21:37:33 GMT+0200 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
0May 02, 2026 21:37:33 GMT+0200++++++

This format is valid for all browsers in our hands, including Internet Explorer, Google Chrome, Firefox, Safari, Opera, Mobile Safari. On PHP, you get this DateTime format of the current time by

<?php
$objDateTime = new DateTime();
$strDateTime = $objDateTime->format("M d, Y H:i:s \G\M\TO");
?>
One observes that this is the Standard English Date Time expression.

1. Another Good Format "mmm dd yyyy hh:mm:ss GMT+0200"

For example, May 02 2026 21:37:33 GMT+0200 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
1May 02 2026 21:37:33 GMT+0200++++++

This format is also valid for all browsers in our hands, including IE, Google Chrome, Firefox, Safari, Opera, Safari Mobile. On PHP, you get this DateTime format of the current time by

<?php
$objDateTime = new DateTime();
$strDateTime = $objDateTime->format("M d Y H:i:s \G\M\TO");
?>
One notes that this is another English Date Time expression with timezone.

2. Good Format "mmm dd, yyyy hh:mm:ss GMT+2"

For example, May 02, 2026 21:37:33 GMT+2 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
2May 02, 2026 21:37:33 GMT+2++++++
As shown, you can shorten the timezone notification.

Bad Formats

All following date time strings are good for some browsers, but unfortunately bad for others.

3. Format "yyyy-mm-dd hh:mm:ss GMT+0200"

For example, 2026-05-02 21:37:33 GMT+0200 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
32026-05-02 21:37:33 GMT+0200-+--++

4. Format "yyyy-mm-dd hh:mm:ss GMT+02:00"

For example, 2026-05-02 21:37:33 GMT+02:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
42026-05-02 21:37:33 GMT+02:00-+--++

4. Format "yyyy-mm-dd hh:mm:ss GMT+0200"

For example, 2026-05-02 21:37:33 GMT+02:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
52026-05-02 21:37:33 GMT+200-+--++

6. Format "dd mmm yyyy hh:mm:ss+02:00"

For example, 02 May 2026 21:37:33+02:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
602 May 2026 21:37:33+02:00-+----

7. Format "mmm dd yyyy hh:mm:ss GMT+02:00"

For example, May 02 2026 21:37:33 GMT+2:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
7May 02 2026 21:37:33 GMT+2:00-++-++

8. Format "mmm dd, yyyy hh:mm:ss GMT+02:00"

For example, May 02, 2026 21:37:33 GMT+02:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
8May 02, 2026 21:37:33 GMT+02:00-++-++

9. Format "yyyy-mmm-dd hh:mm:ss GMT+2"

For example, 2026-05-02 21:37:33 GMT+2 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
92026-05-02 21:37:33 GMT+2-+--++

10. Format "yyyy-mmm-dd hh:mm:ss"

For example, 2026-05-02 21:37:33 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
102026-05-02 21:37:33-+--++

11. Format "yyyy-mmm-ddThh:mm:ss+02:00"

For example, 2026-05-02T21:37:33+02:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
112026-05-02T21:37:33+02:00+++++-
You get this format by PHP5 DateTime=>format('c'). It's regrettable that JavaScript Mobile Safari does not support this format, as this is the universal date time string, used by SQL server, MySQL Server, ...

12. Format "yyyy-mmm-dd hh:mm:ss GMT+02:00"

For example, 2026-05-02 21:37:33+02:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
122026-05-02 21:37:33+02:00-+----

13. Format "mm-dd-yyyy hh:mm:ss GMT+0200"

For example, 05-02-2026 21:37:33 GMT+0200 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
1305-02-2026 21:37:33 GMT+0200++---+

14. Format "mm/dd, yyyy hh:mm:ss GMT+0200"

For example, 05/02, 2026 21:37:33 GMT+0200 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
1405/02, 2026 21:37:33 GMT+0200+++-++

JavaScript new Date() running results at one single glance under Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

Below, we summarize the date time feed checked above in a single table under your current browser.

#PHP DateTime->formatjs new Date() Feedjs new Date() outputs
0M d, Y H:i:s \G\M\TOMay 02, 2026 21:37:33 GMT+0200
1M d Y H:i:s \G\M\TOMay 02 2026 21:37:33 GMT+0200
2May 02, 2026 21:37:33 GMT+2
3Y-m-d H:i:s \G\M\TO2026-05-02 21:37:33 GMT+0200
4Y-m-d H:i:s \G\M\TP2026-05-02 21:37:33 GMT+02:00
52026-05-02 21:37:33 GMT+200
6d M Y H:i:s \G\M\TP02 May 2026 21:37:33+02:00
7May 02 2026 21:37:33 GMT+2:00
8M d Y H:i:s \G\M\TPMay 02, 2026 21:37:33 GMT+02:00
92026-05-02 21:37:33 GMT+2
10Y-m-d H:i:s2026-05-02 21:37:33
11c2026-05-02T21:37:33+02:00
12Y-m-d H:i:sP2026-05-02 21:37:33+02:00
13m-d-Y H:i:s\G\M\TO05-02-2026 21:37:33 GMT+0200
14m/d, Y H:i:s\G\M\TO05/02, 2026 21:37:33 GMT+0200
15d-M-Y H:i:s \G\M\TO02-May-2026 21:37:33 GMT+0200
Tab II: Real-Time JavaScript Date() Results with different Date time feed. See php.net: date — Format a local time/date.

Here the column "PHP DateTime->format" gives the format string to be used to obtain the "js new Date() Feed" column for JavaScript Date Constructor. The last column "js new Date() outputs" is JavaScript running results given by new Date(Date-Time String):

<script type="text/javascript">
document.write(new Date("May 02, 2026 21:37:33 GMT+0200"));
</script>

提供反馈意见 (14)

4. 来访者 *.*.5.* - 2020-12-23 21:04:30
For example, if you were asked to compare how two poets address a similar theme you would know that the reader was expecting to see close analysis of the words used and how theme and structure differ in each.
3. 来访者 *.*.132.* - 2020-11-13 13:42:04
It is very difficult for a child who is not interested in learning to apply the knowledge gained in practice, and the lack of motivation for the educational process leads to chronic academic failure. Why is this happening? The parents themselves are often to blame.
2. 来访者 *.*.255.* - 2020-08-19 01:34:46
Be careful with who you pay to do this, bad people everywhere.
1. 来访者 *.*.177.* - 2020-01-25 21:36:29
Essay company hires only the best writers on the market. We appreciate people with PhD degree. They are expert in every field. You can be sure your psper is in good hands and you'll receive it asap
电子信箱 网站地址

请在空格里打入以下安全字符串:
拷贝字符串。

中国鞋子 > Test Valid Date String for JavaScript
  
爆起窗口    关闭
请耐心等待内容的到来...