Answer the question
In order to leave comments, you need to log in
How to convert date as string to UTC (timestamp)?
How to convert date as string to UTC (timestamp)?
That is, the date "07/15/2019" into an integer.
So that I could create an object of the DateTime class based on this number in php
As I understand it, in JS this question is quite relevant.
What if the order of "2019.07.15" changes
Answer the question
In order to leave comments, you need to log in
Decision!
export function StrDateToUnix(strDate) {
let year, month, day
[year, month, day] = strDate.split("-")
console.log(year, month, day)
return Math.round(new Date(year, month-1, day).getTime()/1000)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question