JavaScriptで時間を扱うならMoment.js

1
var now = moment();
1
var date = moment.unix(1318781876);
1
2
now.format(); // => 2014-05-22T16:53:16+09:00
date.format('YYYY/MM/DD'); // => 2011/10/17
1
date.fromNow(); // => 3 years ago
1
2
3
4
5
6
7
var now = moment();
console.debug('now:', now.format());

var date = moment.unix(1318781876);
console.debug('date:', date.format('YYYY/MM/DD'));

console.debug('fromNow:', date.fromNow());
1
2
3
4
yo webapp
bower install -S momentjs
grunt bowerInstall
grunt serve
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy