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.

Shun Yamada
  • 879
  • 1
  • 10
  • 25
  • Possible duplicate of [Convert datetime string to UTC in JavaScript](https://stackoverflow.com/questions/31163409/convert-datetime-string-to-utc-in-javascript) – Glorious Kale Oct 27 '18 at 13:08

1 Answers1

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()
Root
  • 2,301
  • 1
  • 10
  • 14