Javascript Convert Date Time string to Epoch

后端 未结 8 807
攒了一身酷
攒了一身酷 2020-11-30 09:46

so I give up...been trying to do this all day;

I have a string that supplies a date and time in the format dd/MM/yyyy hh:mm (04/12/2012 07:00

相关标签:
8条回答
  • 2020-11-30 10:18

    i used this code to convert my string datetime to epoch

    new Date(<datetime string>').getTime()
    

    for example :

    let epoch = new Date('2016-10-11').getTime()
    
    0 讨论(0)
  • 2020-11-30 10:21

    My answer is to convert current time to epoch time using JavaScript

    const currentDate = Math.floor(new Date() / 1000);

    console.log(currentDate); //whatever value it will print you can check the same value to this website https://www.epochconverter.com/ to confirm.

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