03-21-2023 11:03 AM
This should be dead simple.
Date/Time String: 3/9/2023 5:51:23 PM
Convert to Timestamp.
Why is this so complicated?
Solved! Go to Solution.
03-21-2023 11:14 AM
Because date and time is a very difficult topic to handle correctly!
However the principal problem is not that hard. You can use for your case Scan from String with a format string of
%<%m/%d/%Y %I:%M:%S %p>T
The real problem starts if this is not your local time zone but something else.
For a UTC timestamp you could change it to
%^<%m/%d/%Y %I:%M:%S %p>T
Other timezone handling is tricky. And you may also have to check if your date is really MM/DD/YYYY. It usually is if you use slashes as separator but it does not have to be.
03-21-2023 11:19 AM
I'd been struggling with the Scan from String examples and just figured it out.
You posted the same solution I came to. Thanks for quick reply!