发表日子 2013-05-31 20:44:00
最后修正 2023-11-22 15:29:06
<script type="text/javascript"> var objDate; objDate = new Date("Nov 21, 2024 14:29:56 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() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
0 | Nov 21, 2024 14:29:56 GMT+0100 | + | + | + | + | + | + |
1 | Nov 21 2024 14:29:56 GMT+0100 | + | + | + | + | + | + |
2 | Nov 21, 2024 14:29:56 GMT+1 | + | + | + | + | + | + |
3 | 2024-11-21 14:29:56 GMT+0100 | - | + | - | - | + | + |
4 | 2024-11-21 14:29:56 GMT+01:00 | - | + | - | - | + | + |
5 | 2024-11-21 14:29:56 GMT+100 | - | + | - | - | + | + |
6 | 21 Nov 2024 14:29:56+01:00 | - | + | - | - | - | - |
7 | Nov 21 2024 14:29:56 GMT+1:00 | - | + | + | - | + | + |
8 | Nov 21, 2024 14:29:56 GMT+01:00 | - | + | + | - | + | + |
9 | 2024-11-21 14:29:56 GMT+1 | - | + | - | - | + | + |
10 | 2024-11-21 14:29:56 | - | + | - | - | + | + |
11 | 2024-11-21T14:29:56+01:00 | + | + | + | + | + | - |
12 | 2024-11-21 14:29:56+01:00 | - | + | - | - | - | - |
13 | 11-21-2024 14:29:56 GMT+0100 | + | + | - | - | - | + |
14 | 11/21, 2024 14:29:56 GMT+0100 | + | + | + | - | + | + |
15 | 21-Nov-2024 14:29:56 GMT+0100 | - | + | - | + | - | + |
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 "2024-11-21 14:29:56" to fit JavaScript syntax in all browsers. Please check this with your preferred browser.
Below, the bold date time outputs at the right hand side of => are the JavaScript Date Class results.
For example, Nov 21, 2024 14:29:56 GMT+0100 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
0 | Nov 21, 2024 14:29:56 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.
For example, Nov 21 2024 14:29:56 GMT+0100 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
1 | Nov 21 2024 14:29:56 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.
For example, Nov 21, 2024 14:29:56 GMT+1 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
2 | Nov 21, 2024 14:29:56 GMT+1 | + | + | + | + | + | + |
All following date time strings are good for some browsers, but unfortunately bad for others.
For example, 2024-11-21 14:29:56 GMT+0100 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
3 | 2024-11-21 14:29:56 GMT+0100 | - | + | - | - | + | + |
For example, 2024-11-21 14:29:56 GMT+01:00 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
4 | 2024-11-21 14:29:56 GMT+01:00 | - | + | - | - | + | + |
For example, 2024-11-21 14:29:56 GMT+01:00 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
5 | 2024-11-21 14:29:56 GMT+100 | - | + | - | - | + | + |
For example, 21 Nov 2024 14:29:56+01:00 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
6 | 21 Nov 2024 14:29:56+01:00 | - | + | - | - | - | - |
For example, Nov 21 2024 14:29:56 GMT+1:00 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
7 | Nov 21 2024 14:29:56 GMT+1:00 | - | + | + | - | + | + |
For example, Nov 21, 2024 14:29:56 GMT+01:00 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
8 | Nov 21, 2024 14:29:56 GMT+01:00 | - | + | + | - | + | + |
For example, 2024-11-21 14:29:56 GMT+1 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
9 | 2024-11-21 14:29:56 GMT+1 | - | + | - | - | + | + |
For example, 2024-11-21 14:29:56 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
10 | 2024-11-21 14:29:56 | - | + | - | - | + | + |
For example, 2024-11-21T14:29:56+01:00 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
11 | 2024-11-21T14:29:56+01:00 | + | + | + | + | + | - |
For example, 2024-11-21 14:29:56+01:00 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
12 | 2024-11-21 14:29:56+01:00 | - | + | - | - | - | - |
For example, 11-21-2024 14:29:56 GMT+0100 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
13 | 11-21-2024 14:29:56 GMT+0100 | + | + | - | - | - | + |
For example, 11/21, 2024 14:29:56 GMT+0100 =>
# | js new Date() Feed | IE | Chrome | Firefox | Safari | Opera | Mobile |
---|---|---|---|---|---|---|---|
14 | 11/21, 2024 14:29:56 GMT+0100 | + | + | + | - | + | + |
Below, we summarize the date time feed checked above in a single table under your current browser.
# | PHP DateTime->format | js new Date() Feed | js new Date() outputs |
---|---|---|---|
0 | M d, Y H:i:s \G\M\TO | Nov 21, 2024 14:29:56 GMT+0100 | |
1 | M d Y H:i:s \G\M\TO | Nov 21 2024 14:29:56 GMT+0100 | |
2 | Nov 21, 2024 14:29:56 GMT+1 | ||
3 | Y-m-d H:i:s \G\M\TO | 2024-11-21 14:29:56 GMT+0100 | |
4 | Y-m-d H:i:s \G\M\TP | 2024-11-21 14:29:56 GMT+01:00 | |
5 | 2024-11-21 14:29:56 GMT+100 | ||
6 | d M Y H:i:s \G\M\TP | 21 Nov 2024 14:29:56+01:00 | |
7 | Nov 21 2024 14:29:56 GMT+1:00 | ||
8 | M d Y H:i:s \G\M\TP | Nov 21, 2024 14:29:56 GMT+01:00 | |
9 | 2024-11-21 14:29:56 GMT+1 | ||
10 | Y-m-d H:i:s | 2024-11-21 14:29:56 | |
11 | c | 2024-11-21T14:29:56+01:00 | |
12 | Y-m-d H:i:sP | 2024-11-21 14:29:56+01:00 | |
13 | m-d-Y H:i:s\G\M\TO | 11-21-2024 14:29:56 GMT+0100 | |
14 | m/d, Y H:i:s\G\M\TO | 11/21, 2024 14:29:56 GMT+0100 | |
15 | d-M-Y H:i:s \G\M\TO | 21-Nov-2024 14:29:56 GMT+0100 |
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("Nov 21, 2024 14:29:56 GMT+0100")); </script>