I am developing an application using Javascript. Within the code, I am receiving the Datetime. This Datetime can have the timezone offset or not. I would like to check if the timezone offset is present or not based on which I need to make a few decisions.
Following is the type of data that will come into my Javascript function:
const dateWithoutOffset = "2022-03-01T16:23:19"
const dateWithOffset = "2022-03-01T16:23:19+01:00"
//Perform something to check for offset
if(dateWithOffset.contains(offset)){
console.log("OFFSET is PRESENT")
}
//Perform something to check offset is not present
if(dateWithoutOffset.contains(offset)){
console.log("OFFSET IS NOT PRESENT")
}
I know that I can check for length but I feel it's not the right way so thought of asking here and finding the right way to find the offset.
I tried a lot of methods and answers present within Stackoverflow but nothing seems to give me the right answer so posting here to get a correct working answer.