Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34500
| From | Joao Rodrigues <groups_jr-1@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale |
| Date | 2018-01-07 13:07 -0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <p2td2l$1qgt$1@gioia.aioe.org> (permalink) |
| References | <9acafc2f-1bc7-442f-adb7-ee34368545a8@googlegroups.com> <p2qodd$1rd5$1@gioia.aioe.org> <49e9404e-ae0e-4e2c-ab90-bb1afd2b5409@googlegroups.com> |
On 06/01/2018 17:18, Dr J R Stockton wrote:
> On Saturday, January 6, 2018 at 3:02:17 PM UTC, Joao Rodrigues wrote:
>> On 31/12/2017 15:57, Dr J R Stockton wrote:
>>> All of my PCs are set, everywhere that I have found, to
>>> use UK, English, and ISO 8601, including the 24-hour clock.
>>> ...
>
>> You may use .toLocaleTimeString() with the new locales and options
>> arguments [1]:
>>
>> var date = new Date();
>> var options = {
>> year: 'numeric', month: 'numeric', day: 'numeric',
>> hour: 'numeric', minute: 'numeric', second: 'numeric',
>> hour12: false,
>> timeZone: 'GMT' // London - UK
>> };
>>
>> console.log(date.toLocaleTimeString('en-GB', options));
>> // 06/01/2018, 14:57:25
>
>
> toLocaleTimeString SHOULD NOT give the _date_, so either the spec or the implementation is WRONG.
The Date.prototype.toLocaleTimeString method indeed returns a time as a
string value (implementation-dependent) in the current time zone that is
appropriate to the host environment's current locale or a specified locale.
Modern browsers implement the Date.prototype.toLocaleTimeString method
as specified in the ECMA-402 Internationalization API.
In the example above, the locales parameter was specified as 'en-GB' and
the options parameter was used to customise the returning string. I
apologise for adding the date portion in the formatting options as this
was misleading to you, however I only did that to show what can be done
with that parameter.
>
>> Or use the Intl object from the ECMAScript Internationalization API [2]
>> directly:
>>
>> console.log(new Intl.DateTimeFormat('en-GB', options).format(date));
>
> It can give the same, but that format is not ISO8601:2004 (which, according to Wikipedia, is the latest). Date field order wrong, date separator wrong. date/time separator wrong.
As I said above, I used the options parameter to format the returning
string as "date, time", but I recognise that was not a good idea given I
was using the toLocaleTimeString() method. :-(
> The method appears unknown to IE11 in Win7.
As of IE 11 in standards document mode, toLocaleTimeString() uses
Intl.DateTimeFormat internally to format the time, which adds support
for the locales and options arguments:
<https://docs.microsoft.com/en-us/scripting/javascript/reference/tolocaletimestring-method-date-javascript>
But it seems to me that IE 11 doesn't recognise some values for the
options parameter such as "GMT" for timeZone. So I have rewritten the
the example as below to work in IE 11 under Win 10:
var date = new Date();
var options = {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false
};
document.write('<p>' + date.toLocaleTimeString('en-GB', options) + '</p>');
>
> Also, timeZone is a terminological ineptitude; a Time Zone is defined as the set of places which, in local winter, have the same offset from GMT/UTC.
>
ECMAScript implementations must recognize at least "UTC" for timeZone in
the options parameter. The default is the runtime's default time zone.
Implementations may also recognize the time zone names of the IANA time
zone database, such as "Asia/Shanghai", "Asia/Kolkata", "America/New_York".
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString>
--
Joao Rodrigues
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2017-12-31 09:57 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-12-31 20:48 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale JJ <jj4public@vfemail.net> - 2018-01-02 04:41 +0700
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-01 23:37 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-03 02:25 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-03 12:55 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-04 04:02 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Martin Honnen <martin.honnen@gmx.de> - 2018-01-04 13:30 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-04 16:48 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Joao Rodrigues <groups_jr-1@yahoo.com> - 2018-01-06 13:02 -0200
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-06 11:18 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Joao Rodrigues <groups_jr-1@yahoo.com> - 2018-01-07 13:07 -0200
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-07 12:19 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-08 11:43 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-08 13:26 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-08 16:36 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-08 06:09 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-08 16:33 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-08 18:58 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-08 19:33 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-08 20:26 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-08 22:10 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-09 02:55 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-09 09:36 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-09 02:10 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-09 03:35 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Andrew Poulos <ap_prog@hotmail.com> - 2018-01-09 15:51 +1100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-09 13:17 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-09 14:44 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-09 14:13 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Andrew Poulos <ap_prog@hotmail.com> - 2018-01-10 17:28 +1100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-10 21:01 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-10 21:00 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-09 13:19 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-20 08:43 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-21 15:09 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-21 17:25 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-21 16:41 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-21 19:15 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-21 18:56 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-21 21:58 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-21 23:03 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-22 10:41 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Joao Rodrigues <groups_jr-1@yahoo.com> - 2018-01-22 11:17 -0200
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-22 14:23 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-23 03:50 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-23 04:41 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-23 08:55 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-23 14:44 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-23 20:04 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-23 23:10 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-23 08:44 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-23 03:24 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-01-23 13:27 -0800
Zulu time (was: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-24 00:44 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Joao Rodrigues <groups_jr-1@yahoo.com> - 2018-01-24 01:37 -0200
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-24 04:57 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-24 04:10 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Joao Rodrigues <groups_jr-1@yahoo.com> - 2018-01-24 10:19 -0200
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-25 08:20 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-25 10:26 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-25 14:26 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Andrew Poulos <ap_prog@hotmail.com> - 2018-01-26 15:42 +1100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-26 11:19 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Andrew Poulos <ap_prog@hotmail.com> - 2018-01-27 07:16 +1100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-26 23:22 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Andrew Poulos <ap_prog@hotmail.com> - 2018-01-27 10:33 +1100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-27 11:30 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Andrew Poulos <ap_prog@hotmail.com> - 2018-01-28 07:38 +1100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-27 23:47 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Andrew Poulos <ap_prog@hotmail.com> - 2018-01-28 10:07 +1100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Mark-" <nospam@mapson.xyz> - 2018-01-28 01:14 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-28 05:25 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Andrew Poulos <ap_prog@hotmail.com> - 2018-01-28 16:07 +1100
[OT] Fallacies (was: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-01-28 07:18 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-24 13:51 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Joao Rodrigues <groups_jr-1@yahoo.com> - 2018-01-24 17:13 -0200
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-23 03:00 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-23 14:14 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-23 15:44 +0100
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-23 04:24 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-01-23 14:29 +0000
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-23 03:19 -0800
Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale Dr J R Stockton <J.R.Stockton@physics.org> - 2018-01-25 13:33 -0800
csiph-web