Skip to content

Instantly share code, notes, and snippets.

@abcdeepakr
Last active November 8, 2023 09:42
Show Gist options
  • Save abcdeepakr/ef5bd8e5755d9d383967dee45d7537ef to your computer and use it in GitHub Desktop.
Save abcdeepakr/ef5bd8e5755d9d383967dee45d7537ef to your computer and use it in GitHub Desktop.
to local from unix
export function parseUnixTimeStamp(unix_timestamp){
var date = new Date(unix_timestamp);
// var hours = date.getHours();
// var minutes = "0" + date.getMinutes();
let parsedDate = date.toLocaleString([], {year: 'numeric', month: 'numeric', day: 'numeric',hour: '2-digit', minute:'2-digit'})
// or
parsedDate = date.toLocaleString([], {year: 'numeric', month: 'short', day: 'short',hour: '2-digit', minute:'2-digit'})
// or
parsedDate = date.toLocaleString([], {year: 'numeric', month: 'long', day: 'long',hour: '2-digit', minute:'2-digit'})
return parsedDate // 08/02/2023, 08:18
}
let date = new Date()
date.toLocaleString("en-IN",{
weekday: "short",
year: "numeric",
month: "long",
day: "numeric",
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment