As the title stated, I want to get the start time and end time of a day for certain timezone and convert them to utc time. Here is my part of my implementation:
//convert current local time to specified timezone time
var converted = moment.tz(moment(), timezone).format("YYYY-MM-DD");
var full_format = "YYYY-MM-DD HH:mm:ss";
// get start time and end time in the timezone
var start = converted + " 00:00:00";
var end = converted + " 23:59:59";
// how to convert them in utc time by momentjs or other methods?
var utc_start_time = ?
var utc_end_time = ?
The question is how to convert the time in certain timezone to utc time. Or is there any other decent solutions to it? Thank you!
Edit:
I figured out a way to make it myself which is not quite decent.
var converted = moment.tz(moment(), timezone).format("YYYY-MM-DD");
var full_format = "YYYY-MM-DD HH:mm:ss";
var start = converted + " 00:00:00";
var end = converted + " 23:59:59";
var utc_start_time = moment(start).add(utc_offset * -1, 'hours').format(full_format);
var utc_end_time = moment(end).add(utc_offset * -1, 'hours').format(full_format);
Any suggestions on improvements are welcome. Thanks