Sergey Khmelevskoy
Sergey Khmelevskoy

Reputation: 2544

Convert date & time string to moment.js with timezone

I have user inputs of meeting_time which is javascript Date (calendar select) and meeting_time string (select dropdown option)

var userTime = meeting_time ? meeting_time.label.split(' -')[0] : null
var userDate = moment(meeting_date).format("YYYY-MM-DD");

How Do I converting those variable to moment.js object with specific timezone

For example,

I want to get moment _d Thu Jul 12 2018 20:00:00 GMT+0800 (UTC +3 to UTC +8)

Upvotes: 0

Views: 51

Answers (1)

yBrodsky
yBrodsky

Reputation: 5041

You can set the hour and minute in the date.

const [hour, minute] = userTime.split(':');
moment(meeting_date).hour(hour).minute(minute).toDate();

Upvotes: 1

Related Questions