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

  • boburnham

    boburnham

    11 Temmuz 2006
  • Apple&Tech Reviews & Giveaways

    Apple&Tech R

    12 Temmuz 2008
  • Klemens Torggler

    Klemens Torg

    11 Mart 2008