getMinutes() 0-9 - How to display two digit numbers?

后端 未结 21 1520
南笙
南笙 2020-12-01 00:42
var date = \"2012-01-18T16:03\";
var date = new Date(date);

console.log(date.getMinutes());
console.log(date.getMinutes().length)

This returns 3.

21条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 00:50

    $(".min").append( (date.getMinutes()<10?'0':'') + date.getMinutes() );
    

    new to JS so this was very helpful the most ppl looking at this prob new too so this is how i got it to show in the div called "class="min"

    hope it helps someone

提交回复
热议问题