I am working in boomi middle ware so can't use any libraries like moment js which has the solution that i can use like following:
function toTimeZone(time, zone) { var format = 'YYYY/MM/DD HH:mm:ss ZZ'; return moment(time, format).tz(zone).format(format);}
I will be receiving
- the date in the middleware as "yyyy-MM-dd HH:mm:ss"
- the date is not UTC. Depending upon the originating request, i know the time zone of this date which could be America/New_York (EST) or America/Los_Angeles (PST) etc
How can i convert this datetime to UTC?
Here is what i am trying to do
var myDate = new Date("2020-02-27 11:19:00").toDateString("en-US", {timeZone: "America/Los_Angeles"});document.write(myDate +'<br>'); //.toDateString() toLocaleStringmyDate = new Date(myDate);document.write(myDate.getFullYear() +"-"+ (myDate.getMonth() + 1) +"-"+ myDate.getDate() +""+ myDate.getHours() +":"+ myDate.getMinutes() +":"+ myDate.getSeconds());
and this is resulting in following. I have lost my time.
Thu Feb 27 20202020-2-27 0:0:0