Test Valid Date String for JavaScript

Created 2013-05-31 20:44:00
Updated 2020-06-02 00:22:41

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("Dec 06, 2021 19:13:50 GMT+0100");
<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
0Dec 06, 2021 19:13:50 GMT+0100++++++
1Dec 06 2021 19:13:50 GMT+0100++++++
2Dec 06, 2021 19:13:50 GMT+1++++++
32021-12-06 19:13:50 GMT+0100-+--++
42021-12-06 19:13:50 GMT+01:00-+--++
52021-12-06 19:13:50 GMT+100-+--++
606 Dec 2021 19:13:50+01:00-+----
7Dec 06 2021 19:13:50 GMT+1:00-++-++
8Dec 06, 2021 19:13:50 GMT+01:00-++-++
92021-12-06 19:13:50 GMT+1-+--++
102021-12-06 19:13:50-+--++
112021-12-06T19:13:50+01:00+++++-
122021-12-06 19:13:50+01:00-+----
1312-06-2021 19:13:50 GMT+0100++---+
1412/06, 2021 19:13:50 GMT+0100+++-++
1506-Dec-2021 19:13:50 GMT+0100-+-+-+
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 "2021-12-06 19:13:50" 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, Dec 06, 2021 19:13:50 GMT+0100 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
0Dec 06, 2021 19:13:50 GMT+0100++++++

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, Dec 06 2021 19:13:50 GMT+0100 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
1Dec 06 2021 19:13:50 GMT+0100++++++

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, Dec 06, 2021 19:13:50 GMT+1 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
2Dec 06, 2021 19:13:50 GMT+1++++++
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, 2021-12-06 19:13:50 GMT+0100 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
32021-12-06 19:13:50 GMT+0100-+--++

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

For example, 2021-12-06 19:13:50 GMT+01:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
42021-12-06 19:13:50 GMT+01:00-+--++

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

For example, 2021-12-06 19:13:50 GMT+01:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
52021-12-06 19:13:50 GMT+100-+--++

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

For example, 06 Dec 2021 19:13:50+01:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
606 Dec 2021 19:13:50+01:00-+----

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

For example, Dec 06 2021 19:13:50 GMT+1:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
7Dec 06 2021 19:13:50 GMT+1:00-++-++

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

For example, Dec 06, 2021 19:13:50 GMT+01:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
8Dec 06, 2021 19:13:50 GMT+01:00-++-++

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

For example, 2021-12-06 19:13:50 GMT+1 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
92021-12-06 19:13:50 GMT+1-+--++

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

For example, 2021-12-06 19:13:50 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
102021-12-06 19:13:50-+--++

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

For example, 2021-12-06T19:13:50+01:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
112021-12-06T19:13:50+01: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, 2021-12-06 19:13:50+01:00 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
122021-12-06 19:13:50+01:00-+----

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

For example, 12-06-2021 19:13:50 GMT+0100 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
1312-06-2021 19:13:50 GMT+0100++---+

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

For example, 12/06, 2021 19:13:50 GMT+0100 =>

#js new Date() FeedIEChromeFirefoxSafariOperaMobile
1412/06, 2021 19:13:50 GMT+0100+++-++

JavaScript new Date() running results at one single glance under CCBot/2.0 (https://commoncrawl.org/faq/)

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\TODec 06, 2021 19:13:50 GMT+0100
1M d Y H:i:s \G\M\TODec 06 2021 19:13:50 GMT+0100
2Dec 06, 2021 19:13:50 GMT+1
3Y-m-d H:i:s \G\M\TO2021-12-06 19:13:50 GMT+0100
4Y-m-d H:i:s \G\M\TP2021-12-06 19:13:50 GMT+01:00
52021-12-06 19:13:50 GMT+100
6d M Y H:i:s \G\M\TP06 Dec 2021 19:13:50+01:00
7Dec 06 2021 19:13:50 GMT+1:00
8M d Y H:i:s \G\M\TPDec 06, 2021 19:13:50 GMT+01:00
92021-12-06 19:13:50 GMT+1
10Y-m-d H:i:s2021-12-06 19:13:50
11c2021-12-06T19:13:50+01:00
12Y-m-d H:i:sP2021-12-06 19:13:50+01:00
13m-d-Y H:i:s\G\M\TO12-06-2021 19:13:50 GMT+0100
14m/d, Y H:i:s\G\M\TO12/06, 2021 19:13:50 GMT+0100
15d-M-Y H:i:s \G\M\TO06-Dec-2021 19:13:50 GMT+0100
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("Dec 06, 2021 19:13:50 GMT+0100"));
</script>

Give us feedback (13)

Add URL |
8. Visitor *.*.102.* - 2021-01-28 17:10:47
Though writing a descriptive or argumentative college essay often does not require any special knowledge, you may find this task unbearable. Our customers tell us about various reasons why they decide to buy essays online, including difficulties with managing their time, problems in life, part-time job, family, and other chores. Whatever your case is, our experts are always here to help.
7. Visitor *.*.218.* - 2021-01-23 23:56:12
24/7 availability. Once you order an essay from us, we ensure that constant communication is maintained to keep you informed regarding the progress of your order. To make this possible, our support team is available round-the-clock for calls and emails from our customers. This makes it possible for you to contact us anytime and get a prompt reply concerning our services.
6. Visitor *.*.106.* - 2021-01-22 11:54:09
You may wonder what’s the difference between streaming and downloading. Downloading requires you to save an entire copy of the file to your device.
5. Visitor *.*.253.* - 2021-01-12 11:02:06
Impressive sample essays of other writers do not mean that you will get to cooperate with one of them. So, once you get to have a chat with your writer, ask them to send you a sample of their previously completed orders
4. Visitor *.*.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.
Email Web

Please copy the string:
String to copy.

Asia Home™ > Tools > Test Valid Date String for JavaScript | General Sales Conditions | Returns and refunding | Privacy Policy | FAQ
  

Want to come? | Call us 7/700 33 467 790 487 (no surcharge)

Monday
09:00 - 21:30
☚Open, please come in...
Merry Feasts! Chinese New Year Since 297 days !Merry Feasts! Chinese New Year Since 297 days !
Popup Window    Close
Patience please...