Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    i believe it will be helpful to has plugin offer this function,
    and thanks,
    When is the next release planned?
    I need this fix iamkun/dayjs@e5a257c on my project =)
    @ggraffion-accor released 1.8.15 today
    @iamkun Perfect, thanks!
    Is there Chinese friends use dayjs on wechat mini program?
    const dayjs = require('../../utils/dayjs.min.js')
    const dayjsPluginUTC = require('../../utils/dayjs-plugin-utc.min.js')
    I got an error message:Uncaught TypeError: t is not a function
    Anybody knows how to fix it? Thanks
    @gotounix dayjs.extend(dayjsPluginUTC.default)
    Hi guys, dayjs how to format date to rfc3339 format ? like 2019-12-24T15:59:59Z
    Hi all, is there anyway to have a strict mode.
    import dayjs from 'dayjs';
    import customParseFormat from 'dayjs/plugin/customParseFormat';
    dayjs('2020-13-32', 'YYYY-MM-DD').isValid()  // wrong on both month and year
    in fact
    import dayjs from 'dayjs';
    import customParseFormat from 'dayjs/plugin/customParseFormat';
    dayjs('2020-99-78', 'YYYY-MM-DD').isValid()
    I'm pretty sure I'm doing something very daft as the bottom one is about as invalid as can be
    I am on dayjs@1.8.25
    @dagda1 Yes in next release iamkun/dayjs#882
    stirct mode released dayjs@1.8.26. @dagda1
    Eric Martinez
    Hey guys, I'm using dayjs and the plugin dayjs-business-days
    I've added like this in my class. I'm using Angular.
    import dayjs from 'dayjs';
    import dayjsBusinessDays from 'dayjs-business-days';
    export class Class {
      constructor() {
      add(fechaInicio: Date, dias: number): Date {
        return dayjs(fechaInicio)
    and I created a .d.ts file for it
    import { Dayjs } from 'dayjs';
    declare module 'dayjs' {
      interface Dayjs {
        businessDaysAdd(days: number);
    There's no linting issue, but when I run it I get
    error TS2339: Property 'businessDaysAdd' does not exist on type 'Dayjs'
    Is there something I'm missing?
    @ericmartinezr make sure the d.ts file you added is included in ts config
    Artem Gusev
    Hi everybody :) @iamkun I'm finished docs translation on russian. Please, check it. Thanks
    @CreativeRusBear Cool thanks. I just released a new doc.
    Apoorv Mishra
    Hi everyone :wave: , just published a CLI tool for guessing a date's format at https://github.com/apoorv-mishra/moment-guess. Hope that it might turn out to be useful for dayjs users :smiley:
    Eugene Serkin
    Good evening chat. I was wondering if there is way to globally set, what timezone I wish to use with dayjs?
    @jeserkin No, at present. Feel free to open an issue for this feature request.
    Sabin Bogati

    I'm making a node.js library, and I want it to return a DayJS class, how do I set it up so it returns the DayJS Class (that people can use its methods on), and have it shown in my JSDOCS?
    Do I use

    const dayjs = require('dayjs')


    const { Dayjs } = require('dayjs')


    Basically, I just want to return a dayjs object, and allow people to use it normally.
    @sasial-dev dayjs() will returns you a dayjs obejct

    @iamkun I've gone and updated my code now,

         * TEST
         * @returns {dayjs} 
         * @memberof APIClient
        async test() {
          return dayjs()

    Test Script

    mylib.test().then(day => {
        console.log(day.to(day.add(6, "m")))

    Now while this works (returning a dayjs object), there's no VSC autocomplete or anything?
    How can I set it up so it knows it's returning a dayjs object?

    Yes, this was added at the start of the script.
    const dayjs = require('dayjs')
    // Load DAYJS Plugins
    var relativeTime = require('dayjs/plugin/relativeTime')
    var utc = require('dayjs/plugin/utc') 
    var timezone = require('dayjs/plugin/timezone') // dependent on utc plugin
    Don't worry about this, I'll use a different library, as after looking at the d.ts, it doesn't work for the library I'm using
    Better check your vscode settings.
    Matt Haggard
    How do I retain the offset that was present when I parsed a timestamp? I want to display the timestamp with the original offset regardless of my local offset.
    let a = dayjs("2000-01-01 01:02:03+07:00")
    let b = a.add(1, 'day');
    // what do I do here?
    b.format("YYYY-MM-DD HH:mm:ssZ") === "2000-01-02 01:02:03+07:00"
    John Winston
    Hi, is it possible to get the date of all Saturday of a month in dayjs?
    2 replies
    Can I translate to traditional chinese?
    Kirstin Walsh

    I am having some timezone issues....I have some date/time objects that I have to convert from UTC time to EST. I need to compare the current time to a string that I convert into a date object. I can't seem to find a way to compare the 2 date/times where the comparison returns correctly. When the string that I have converted into a date object is before the current time, it is returning false (not before the current time). I don't understand why this is happening, unless it is because there is no timezone attached to the converted string date. When I try to attach a timezone to it, it doesn't seem to work - or it is attaching the GMT timezone instead of EST timezone. I am not sure what I am doing wrong.

     let deploymentTime = dayjs.tz(`${parseInt(month)+1}/${date}/${year} ${deployHour}:${dataObj.minute.value} ${period}`, "America/New_York").format('M/D/YYYY h:mm a');
                    let otherTime = dayjs(`${parseInt(month)+1}/${date}/${year} ${deployHour}:${dataObj.minute.value} ${period}`).format('M/D/YYYY h:mm a');
                    console.log("DEPLOYMENT time: " +deploymentTime.toString());
                    console.log("other time: " +deploymentTime.toString());
                    console.log(dayjs().tz("America/New_York").isBefore(deploymentTime, 'minute'))
                    console.log(dayjs().tz("America/New_York").isBefore(otherTime, 'minute'))

    logs out:

    [0-0] Tue, 08 Dec 2020 16:58:53 GMT
    DEPLOYMENT time: 12/8/2020 4:00 pm
    other time: 12/8/2020 4:00 pm
    [0-0] true
    [0-0] false
    Kirstin Walsh

    @iamkun I am still striggling to get time in my local timezone. The system I am running in is running in UTC, but I need to convert the time to my local time of EST. I have tried setting the default tiemzone to EST, but when I call dayjs().tz() or dayjs().tz().local() it gives me the same time as just calling dayjs(). How do I convert time from UTC to EST?

    console.log("date: " +dayjs().toString())
    console.log("date with timezone: " +dayjs().tz().toString())
    console.log("date with local timezone: " + dayjs().tz().local().toString())

    logs out:

    date: Tue, 19 Jan 2021 16:53:10 GMT
    [0-0] date with timezone: Tue, 19 Jan 2021 16:53:10 GMT
    [0-0] date with local timezone: Tue, 19 Jan 2021 16:53:10 GMT
    Eric Guan
    need help with getting the nth weekday. like 4th friday of the month, 2nd sunday of the month, etc.
    tried this but not working
    // daynum is 0 to 6, 0 = sunday, 6 = saturday
    // to get the 2nd friday of the current month, call getNthDayOfWeek(5, 2)
    export function getNthDayOfWeek (dayNum, nth) {
        const date = dayjs().startOf('month').add(nth - 1, 'week').day(dayNum)
        return date.toDate()
    the attempted logic is "get the nth week and then the specified day of that week"
    Eric Guan
    date manipulation hurts my brain