extract time from datetime using javascript

前端 未结 8 876
忘掉有多难
忘掉有多难 2020-11-29 07:08

how can i extract time from datetime format.

my datetime format is given below.

var datetime =2000-01-01 01:00:00 UTC;

I only want

相关标签:
8条回答
  • 2020-11-29 08:11
    var date1 = new Date(1945,10,20, 17,30)
    var date2 = new Date(1970,1,8, 12,00)
    
    console.log(date1.getHours() - 8 + (date1.getMinutes()/60))
    
    console.log(date2.getHours() - 8 + (date2.getMinutes()/60))
    
    0 讨论(0)
  • 2020-11-29 08:14

    with the moment.js library it works in this way:

    var result = moment().format('hh');
    alert(result);
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>

    0 讨论(0)
提交回复
热议问题