How to use the dayjs.tz 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 gempir / justlog / web / src / components / LogLine.tsx View on Github external
import dayjs from "dayjs";
import React, { useContext } from "react";
import styled from "styled-components";
import { useThirdPartyEmotes } from "../hooks/useThirdPartyEmotes";
import { store } from "../store";
import { LogMessage } from "../types/log";
import { Message } from "./Message";
import { User } from "./User";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";

dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.tz.guess()

const LogLineContainer = styled.li`
	display: flex;
	align-items: flex-start;
    margin-bottom: 1px;

    .timestamp {
        color: var(--text-dark);
        user-select: none;
        font-family: monospace;
        white-space: nowrap;
        line-height: 1.1rem;
    }

    .user {
        margin-left: 5px;
github replicatedhq / kots / web / src / utilities / utilities.js View on Github external
dateFormat(date, format, localize = true) {
    if (!localize) {
      return dayjs.utc(date).tz(dayjs.tz.guess()).format(format);
    }
    return dayjs.utc(date).local().tz(dayjs.tz.guess()).format(format);
  },
github gempir / justlog / web / src / components / TwitchChatLogLine.tsx View on Github external
import dayjs from "dayjs";
import React, { useContext } from "react";
import styled from "styled-components";
import { useThirdPartyEmotes } from "../hooks/useThirdPartyEmotes";
import { store } from "../store";
import { LogMessage } from "../types/log";
import { Message } from "./Message";
import { User } from "./User";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";

dayjs.extend(utc)
dayjs.extend(timezone)
dayjs.tz.guess()

const TwitchChatLogLineContainer = styled.li`
	align-items: flex-start;
    margin-bottom: 1px;
    padding: 5px 20px;

    .timestamp {
        color: var(--text-dark);
        user-select: none;
        font-family: monospace;
        white-space: nowrap;
        margin-right: 5px;
        line-height: 1.1rem;
    }

    .user {

dayjs

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

MIT
Latest version published 25 days ago

Package Health Score

88 / 100
Full package analysis