1

With Typescript, I want to change date/time format from string to UTC. Currently, that occurs invalid.

like this: 2018/10/27+16:00 => 20181027T01000Z

import * as moment from 'moment'

dates=${moment(`${String(date)}`).format('YYYYMMDD')}T${moment(`${String(time)}`)
     .utc()
     .format('HHmm')}Z/${moment(`${String(date)}`).format('YYYYMMDD')}T${moment(
     `${String(time)}`,
)
     .utc()
     .format('HHmm')}

Adding to this, I want to add 30min to second time.

1

1 Answer 1

1

In moment, you can use add like this to add 30mins

moment().add(30, 'minutes');

And set it to UTC,just use this:

moment.utc().valueOf()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.