how to validate UTC format date

  javascript, regex, typescript

Can you help me how to write a regular expression for the below format?

"2020-02-07 15:45:25.763437 UTC+0000"

my rex should accept the below format also:
"2020-02-07 15:45:25"

I found how to find the "2020-02-07 15:45:25" but I don’t know how I can make the second part optional? can you help me to figure it out, please?

^([0-9]{4})-([0-1][0-9])-([0-3][0-9])s([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$

I am coding in typescript.

Source: Ask Javascript Questions

LEAVE A COMMENT