“UNIX TO Time in JavaScript” Kode Jawaban

Unix Time to Date JavaScript

const unixTime = 1210981217;
const date = new Date(unixTime*1000);
console.log(date.toLocaleDateString("en-US"));
//expected: "5/16/2008"
CharllierJr

UNIX TO Time in JavaScript

const unixToTime = (string) => {
  const unix_timestamp = string;
  const date = new Date(unix_timestamp * 1000);
  const hours = date.getHours();
  const minutes = "0" + date.getMinutes();
  const seconds = "0" + date.getSeconds();
  const newText =
    hours + " : " + minutes.substr(-2) + " : " + seconds.substr(-2);
  
  return newText
};
mrmalik610

Unix hingga saat ini di JavaScript

const unixToDate = (string) => {
  const unixTime = string;
  const date = new Date(unixTime * 1000);
  const newText = date.toLocaleDateString("en-US");
  
  return newText
};
mrmalik610

Konversi tanggal ke javascript waktu unix

new Date('2012.08.10').getTime() / 1000 //secs
new Date('2012.08.10').getTime() //milliseconds
Zealous Zebra

Jawaban yang mirip dengan “UNIX TO Time in JavaScript”

Pertanyaan yang mirip dengan “UNIX TO Time in JavaScript”

Lebih banyak jawaban terkait untuk “UNIX TO Time in JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya