Skip to content

Instantly share code, notes, and snippets.

@romain130492
Last active March 1, 2020 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romain130492/0e390616c9640f303d1a06e686c1049f to your computer and use it in GitHub Desktop.
Save romain130492/0e390616c9640f303d1a06e686c1049f to your computer and use it in GitHub Desktop.
day.js Set an ISO with a specific date & time & UTC
  • Import Modules
import dayjs from 'dayjs'
var utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
  • Date and input User
  <input type="time" v-model="inputDate" />
  <input type="time" v-model="inputTime" />
  • Convert to ISO and set the UTC to 0
  let dateISO = dayjs(this.inputDate)
          .set('hours', this.inputTime.substring(0, 2))
          .set('minute', this.inputTime.substring(3, 5))
          .utc()
          .format()

Source : https://day.js.org/docs/en/parse/utc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment