jquery - How to get the Date & Time format From Client Machine using angular 2 or javascript? -


transform(value: any): {     var customdate = new datepipe(navigator.language);     value = customdate.transform(value,"dd-mm-yyyy");     return value; }    

i need date format of client's machine @ place of "dd-mm-yyyy".

unfortunately, there not seem way preferred format dates browser. can information locale user in, , might able divine appropriate default values. example, following snippet uses ecmascript internationalization api (which released after how local date/time format? answered):

console.log(new intl.datetimeformat().resolvedoptions())    /*  on machine, outputs:  {    "locale": "en-us",    "calendar": "gregory",    "numberingsystem": "latn",    "timezone": "america/new_york",    "year": "numeric",    "month": "numeric",    "day": "numeric"  }  */

from information, should able use server-side language/framework construct necessary format. instance, in .net, using c#:

var culture = system.globalization.cultureinfo.createspecificculture("en-us"); var datetimeinfo = culture.datetimeformat; var formats = datetimeinfo.getalldatetimepatterns(); // formats contains list of formats culture 

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -