How to use the dayjs.utc function in dayjs

To help you get started, we’ve selected a few dayjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sitespeedio / sitespeed.io / lib / sitespeed.js View on Github external
async run(options) {
    const url = options.urls[0];
    const timestamp = options.utc ? dayjs.utc() : dayjs();
    const { storageManager, resultUrls } = resultsStorage(
      url,
      timestamp,
      options.outputFolder,
      options.resultBaseURL,
      options.useHash
    );

    // Setup logging
    const logDir = await storageManager.createDirectory('logs');
    logging.configure(options, logDir);

    // Tell the world what we are using
    log.info(
      'Versions OS: %s nodejs: %s sitespeed.io: %s browsertime: %s coach: %s',
      os.platform() + ' ' + os.release(),
github ENCODE-DCC / encoded / src / encoded / static / components / home.js View on Github external
{newsSearch['@graph'].map(item =>
                        <div>
                            <h3>{item.title}</h3>
                            <h4>{dayjs.utc(item.date_created).format('MMMM D, YYYY')}</h4>
                            <div>{item.news_excerpt}</div>
                            <div>
                                <a for="" aria-label="{`View" href="{item['@id']}">Read more</a>
                            </div>
                        </div>
                    )}
github Flowm / satvis / src / modules / CesiumController.js View on Github external
setTime(current, start = dayjs.utc(current).subtract(12, "hour").toISOString(), stop = dayjs.utc(current).add(7, "day").toISOString()) {
    this.viewer.clock.startTime = Cesium.JulianDate.fromIso8601(dayjs.utc(start).toISOString());
    this.viewer.clock.stopTime = Cesium.JulianDate.fromIso8601(dayjs.utc(stop).toISOString());
    this.viewer.clock.currentTime = Cesium.JulianDate.fromIso8601(dayjs.utc(current).toISOString());
    if (typeof this.viewer.timeline !== "undefined") {
      this.viewer.timeline.updateFromClock();
      this.viewer.timeline.zoomTo(this.viewer.clock.startTime, this.viewer.clock.stopTime);
    }
  }
github checktheroads / hyperglass / hyperglass / ui / util.js View on Github external
const formatTime = val => {
  const now = dayjs.utc();
  const then = now.subtract(val, "seconds");
  const timestamp = then.toString().replace("GMT", "UTC");
  const relative = now.to(then, true);
  return `${relative} (${timestamp})`;
};
github ArcBlock / forge-js / apps / forge-web / src / pages / dashboard / components / metrics.js View on Github external
async function fetchBoth() {
  const date = dayjs.utc().format('YYYY-MM-DD');
  const [{ forgeStats: summary }, { forgeStats: trend }] = await Promise.all([
    forge().getForgeStats(),
    forge().getForgeStatsByHour({ date }),
  ]);

  return { summary, trend };
}
github u2sb / Danmu.Server / Danmu / clientapp / src / components / Admin / Edit / DanmuEdit.vue View on Github external
Form2Data(form) {
      let f = JSON.parse(JSON.stringify(form))
      f.data.color = parseInt(f.data.color.substring(1), 16)
      f.createTime = dayjs.utc(f.createTime)
      f.updateTime = dayjs.utc()
      return f
    }
  },
github ENCODE-DCC / encoded / src / encoded / static / components / file.js View on Github external
{context.assembly ?
                                    <div data-test="assembly">
                                        <dt>Assembly</dt>
                                        <dd>{context.assembly}</dd>
                                    </div>
                                : null}
                                {context.genome_annotation ?
                                    <div data-test="genomeannotation">
                                        <dt>Genome annotation</dt>
                                        <dd>{context.genome_annotation}</dd>
                                    </div>
                                : null}
                                {context.date_created ?
                                    <div data-test="datecreated">
                                        <dt>Date added</dt>
                                        <dd>{dayjs.utc(context.date_created).format('YYYY-MM-DD')}</dd>
                                    </div>
                                : null}

                                {context.dbxrefs &amp;&amp; context.dbxrefs.length &gt; 0 ?
                                    <div data-test="externalresources">
                                        <dt>External resources</dt>
                                        <dd></dd>
                                    </div>
                                : null}

                                {context.content_error_detail ?
                                    <div data-test="contenterrordetail">
                                        <dt>Content error detail</dt>
                                        <dd>{context.content_error_detail}</dd>
                                    </div>
                                : null}
github u2sb / Danmu.Server / Danmu / clientapp / src / components / Admin / DanmuList.vue View on Github external
.select((s, i) => ({
                num: i,
                id: s.id,
                vid: s.vid,
                text: s.data.text,
                ip: s.ip,
                createTime: dayjs.utc(s.createTime).local().format('YYYY-MM-DD HH:mm:ss'),
                updateTime: dayjs.utc(s.updateTime).local().format('YYYY-MM-DD HH:mm:ss'),
                isDelete: s.isDelete ? '是' : '否'
              }))
              .toArray()
github exceljs / exceljs / lib / csv / csv.js View on Github external
(value => {
          if (value) {
            if (value.text || value.hyperlink) {
              return value.hyperlink || value.text || '';
            }
            if (value.formula || value.result) {
              return value.result || '';
            }
            if (value instanceof Date) {
              if (dateFormat) {
                return dateUTC ? dayjs.utc(value).format(dateFormat) : dayjs(value).format(dateFormat);
              }
              return dateUTC ? dayjs.utc(value).format() : dayjs(value).format();
            }
            if (value.error) {
              return value.error;
            }
            if (typeof value === 'object') {
              return JSON.stringify(value);
            }
          }
          return value;
        });
github replicatedhq / kots / web / src / utilities / utilities.js View on Github external
dateFormat(date, format, localize = true) {
    if (!localize) {
      return dayjs.utc(date).format(format);
    }
    return dayjs.utc(date).local().format(format);
  },

dayjs

2KB immutable date time library alternative to Moment.js with the same modern API

MIT
Latest version published 3 months ago

Package Health Score

88 / 100
Full package analysis