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

  • Android Authority

    Android Auth

    3 NİSAN 2011
  • laptopmag

    laptopmag

    25 Ocak 2008
  • Palmundo Ec

    Palmundo Ec

    11 HAZİRAN 2009