Javascript 時間擴展類:dateplus
javascript 極簡時間擴展類
var dateplus=(new Date()).y(2014).m(10).d(27).h(15).M(2);
示例代碼:
require('dateplus'); // get a Date instance by splited number string (only for order by year month day hour minute second microsecond) var d=Date.parseCN('2014.1.1 12:00'); // set month to 10 d.m(10); // set day 1+1=2 d.d('+1') // set hour 12-1=11 d.h('-1'); // set hour 11-1=10 the same d.h(-1); // short for d.getTime(); //1412215200000 d.t(); // d.getTime(); with out microseconds // 1412215200 d.T(); // date format string // 2014-10-02 10:00:00:000 d.format('yyyy-mm-dd hh:MM:ss:SSS'); // default date format string // Date.formats.default (yyyy-mm-dd hh:MM) // 2014-10-02 10:00 d.format(); // other short name for format // Date.formats.date='yyyy-mm-dd' // 2014-10-02 d.format('date'); // Date.formats.long='yyyy-mm-dd hh:MM:ss' // 2014-10-02 10:00:00 d.format('long'); // you can custom by modify Date.formats Date.formats.micro='yyyy-mm-dd hh:MM:ss:SSS'; // 2014-10-02 10:00:00:000 d.format('micro'); // copy a instance var d2=d.clone(); // chain var d3=d.clone().y(2014).m(10).d(27).h(15).M(2);
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!