What’s the best way to subtract a few hours from a time string formatted as such:
8:32 AM
I thought about splitting the string at the colon but when subtracting 3 hours from, say, 1:00 AM I get -2:00 AM instead of the desired 10:00 PM.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Most reliable method is to convert it into a JS date object, then do you math on that
the Date object accepts either year/month/day/hour/minute/second/milliseconds OR a unix-style timestamp of milliseconds-since-Jan-1-1970 for the constructor.