Skip to content

Instantly share code, notes, and snippets.

@webinista
Created November 12, 2021 21:05
Show Gist options
  • Save webinista/c210a5677735a4d6359037d9c95ba03b to your computer and use it in GitHub Desktop.
Save webinista/c210a5677735a4d6359037d9c95ba03b to your computer and use it in GitHub Desktop.
const formatDate = ( dateStr ) => {
let returned = '';
if( 'Intl' in window ) {
const dateObj = new Date( dateStr );
const options = {
month: 'long',
timeZone: 'America/Los_Angeles',
day: 'numeric',
year: 'numeric'
};
let dte = new Intl.DateTimeFormat( 'en-US', options ).format( dateObj );
returned = dte;
}
return returned;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment