var type = new Audio().canPlayType('audio/mpeg') ? 'mp3' : 'ogg';
new Audio('audio.' + type).play();
var d1 = Date.now()
, d2 = Date.parse("Wed, 09 Aug 1995 00:00:00")
, interval = new Date(d1 - d2);
// год.месяц.день.час.минута.секунда
console.log([
interval.getUTCFullYear() - 1970,
interval.getUTCMonth(),
interval.getUTCDate() - 1,
interval.getUTCHours(),
interval.getUTCMinutes(),
interval.getUTCSeconds(),
].join('.')); // => 18.7.19.21.30.9
var string = '1234';
string.match(/(\d\d)/g).reverse(); // => ["34", "12"]
io.sockets.on('connection', function (socket) {
socket.on('disconnect', function () {
// ...
});
});
while(game_is_running){
update_game();
sleep(time);
}
var update = Date.now();
function f(){
var last = update;
update_game();
update = Date.now();
if(game_is_running) setTimeout(f, time - update + last);
}
f();