SORU
11 Mayıs 2009, PAZARTESİ


Javascript zaman bir Unix zaman damgası dönüştürmek

Bir Unix zaman damgası ve bazı Javascript gönderilen alır gibi bir MySQL veritabanında depolamak zaman ben nasıl bu işten sadece zaman gidebilirim? Ex. /MM/SS HH

CEVAP
11 Mayıs 2009, PAZARTESİ


// create a new javascript Date object based on the timestamp
// multiplied by 1000 so that the argument is in milliseconds, not seconds
var date = new Date(unix_timestamp*1000);
// hours part from the timestamp
var hours = date.getHours();
// minutes part from the timestamp
var minutes = "0"   date.getMinutes();
// seconds part from the timestamp
var seconds = "0"   date.getSeconds();

// will display time in 10:30:23 format
var formattedTime = hours   ':'   minutes.substr(-2)   ':'   seconds.substr(-2);

Daha fazla bilgi Tarihi ile ilgili, lütfen MDN ES5 specification nesne bakın.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • graham025

    graham025

    25 NİSAN 2006
  • Julian Smith

    Julian Smith

    31 EKİM 2006
  • mipd1980

    mipd1980

    25 EKİM 2006