时间线

function gettimeLine(){
const now = new Date();

now.setHours( 0 );
now.setMinutes( 0 );
now.setSeconds( 1 );

const year = now.getFullYear();
const month = now.getMonth() + 1;
const $year = now.getFullYear() - ( month < 4 ? 1 : 0 );
const days = ( new Date( `${ $year + 1 }-04-01` ) - new Date( `${ $year }-04-01` ) ) / 86400000;

return ( ( now - new Date( `${ $year }-04-01` ) ) / 86400000 / days * 100 ).toFixed( 2 ) + '%';
}
undefined
gettimeLine()
"30.32%"

posted @ 2017-07-21 18:16  LSunshine  阅读(136)  评论(0编辑  收藏  举报