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

  • Day9TV

    Day9TV

    22 NİSAN 2010
  • MattSteffanina 2

    MattSteffani

    28 Kasım 2007
  • Submissions101

    Submissions1

    23 ŞUBAT 2007