Skip to content

Instantly share code, notes, and snippets.

@akmamun
Created May 19, 2019 08:29
Show Gist options
  • Save akmamun/d89475696b99d3e01cb826815ec4479b to your computer and use it in GitHub Desktop.
Save akmamun/d89475696b99d3e01cb826815ec4479b to your computer and use it in GitHub Desktop.
JS Date Time
const options = {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric'
}
new Intl.DateTimeFormat('en-US', options).format(date) //"7/22/2018, 7:22:13 AM"
new Intl.DateTimeFormat('it-IT', options2).format(date) //"22/7/2018, 07:22:13"
getFormatDateTime = (dateTime) => {
let now = new Date(dateTime);
let options = {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
};
return now.toLocaleString('en-BD', options); //July 1st 2018, 10:20AM
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment