Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34485

Re: new Date().toLocaleTimeString() sponned in Fall Creators Update. UL locale

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-06 13:02 -0200
Organization Aioe.org NNTP Server
Message-ID <p2qodd$1rd5$1@gioia.aioe.org> (permalink)
References <9acafc2f-1bc7-442f-adb7-ee34368545a8@googlegroups.com>

Show all headers | View raw


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.
> 
> JavaScript new Date().toLocaleTimeString() in up-to-date
> Windows 7, final Windows XP, and probably in Windows 98 &
> maybe even in Windows 3.x, and probably also in previous
> Windows 10, gave the 24-hour clock, "HH:MM:SS"
> 
> Today, I allowed a Windows 10 update on my laptop FUJ-2012
> - what arrived was Fall Creators Update, I think.
> 
> In the new update, I get "hh:mm:ss PM".  I expect to see
> AM tomorrow morning. and an wondering whether the hours
> field will have its leading zero before 10:00; I believe
> I've seen corresponding ineptitude somewhere in UTC time.
> 
> That is the case in all of the browsers I tested, which
> are not all that I have.
> 
> I don't know what happens in other locales, but it seems
> likely that Evertjan & others will be able to tell us.
> 

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

Or use the Intl object from the ECMAScript Internationalization API [2] 
directly:

console.log(new Intl.DateTimeFormat('en-GB', options).format(date));

[1] 
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString>
[2] 
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat>

Cheers,
Joao Rodrigues

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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