Babban matsalar canza millise seconds zuwa sa'o'i, mintuna, da daฦiฦa shine cewa ba koyaushe suke daidaitawa ba. Misali, idan kun canza mil 10,000 zuwa sa'o'i, sakamakon zai zama sa'o'i 10. Koyaya, idan kun canza mil 10,000 zuwa mintuna, sakamakon zai zama mintuna 10 da sakan 40.
var date = new Date(milliseconds); var hh = date.getHours(); var mm = date.getMinutes(); var ss = date.getSeconds();
Wannan lambar tana ฦirฦirar sabon abu na kwanan wata ta amfani da milliseconds da aka ba, sannan ya sami sa'o'i, mintuna, da daฦiฦa daga wannan abin kwanan wata.
Lokaci da JavaScript
JavaScript yaren shirye-shirye ne wanda ke gudana a cikin burauzar. Brendan Eich ne ya ฦirฦira shi a cikin 1995 kuma yanzu yana ษaya daga cikin shahararrun yaruka akan yanar gizo.
ฦaya daga cikin mahimman fasalulluka na JavaScript shine ikonsa don gudanar da asynchronously. Wannan yana nufin cewa lambar na iya gudana a layi daya, wanda zai iya sa ayyuka da sauri. JavaScript kuma yana da ginannen ษakin karatu na kwanan wata da lokaci, wanda ke sauฦaฦa aiki tare da kwanan wata da lokuta.
Juya lokaci
Akwai ฦดan hanyoyi don canza lokaci a JavaScript. Hanyar da aka fi amfani da ita ita ce amfani da abin Kwanan wata.
var now = sabon Kwanan wata (); // 12/5/2015 3:00 PM
Hakanan zaka iya amfani da ginanniyar aikin Date.now().
var now = Kwanan wata.yanzu(); // 12/5/2015 3:00 PM