How to use the utc function from dayjs

Find comprehensive JavaScript dayjs.utc code examples handpicked from public code repositorys.

18
19
20
21
22
23
24
25
26
27
const semver = require('semver');
const dayjs = require('dayjs');
const utc = require('dayjs/plugin/utc');
dayjs.extend(utc);

const timestamp = dayjs.utc().format('YYYYMMDDHHmmss');

const lernaDirectory = path.resolve('.');
const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json');
const lernaConfig = require(lernaConfigFile);
fork icon56
star icon151
watch icon16

+ 5 other calls in file

3
4
5
6
7
8
9
10
11
dayjs.extend(utc)

const date = {}

date.utc = d => {
        return dayjs.utc(d)
}

module.exports = date
fork icon363
star icon0
watch icon0

54
55
56
57
58
59
60
61
62
63
const { url, parser } = require('./example.com.config.js')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)

const date = dayjs.utc('2022-11-18', 'YYYY-MM-DD').startOf('d')
const channel = { site_id: 'bbc1', xmltv_id: 'BBCOne.uk', lang: 'en' }

it('can generate valid url', () => {
        expect(url({ channel, date })).toBe('https://example.com/api/bbc1/2022-11-18')
fork icon33
star icon0
watch icon60

+ 5 other calls in file

68
69
70
71
72
73
74
75
76
77
removeStr.forEach((x) => {
    // Order matters
    htmlP = htmlP.replace(RegExp(x, 'gi'), '');
});

const d = dayjs.utc(htmlP, customFormat);
// console.log(htmlP,d)
if (d.isValid()) {
    if (/[+-](\d{2}:?\d{2})/.test(html)) {
        return d.toDate().toUTCString();
fork icon0
star icon0
watch icon1

+ 3 other calls in file