A lightweight javascript timezone library

Overview

Isn't it weird how we can do math in our head, but not date math?

  • how many days until the end of the year?
  • what time was it, 11 hours ago?
  • is it lunchtime in france?

and worse - there is no real date calculator.

people end up asking google, and going to weird websites.

that's bad.

spacetime is working hard to be a date-calculator: It's very small, it's very handy.

let s = spacetime.now()

s.diff(s.endOf('year'), 'days')
// 292

s.minus(11, 'hours').time()
// 6:50am

s = s.now('Europe/Paris')
s.isAfter(s.time('11:00am'))
// true 🥐

  • calculate time in remote timezones
  • support daylight savings, leap years, and hemispheres
  • Moment-like API (but immutable)
  • Orient time by quarter, season, month, week..
  • Zero Dependencies - (no Intl API)
  • weighs about 40kb.
  • has a cool plugin thing.

<script src="https://unpkg.com/spacetime"></script>
<script>
  var d = spacetime('March 1 2012', 'America/New_York')
  //set the time
  d = d.time('4:20pm')

  d = d.goto('America/Los_Angeles')
  d.time()
  //'1:20pm'
</script>

npm install spacetime

const spacetime = require('spacetime')
let d = spacetime.now('Europe/Paris')
d.dayName()
//'Wednesday'
d.isAsleep()
//true

typescript / babel / deno:

import spacetime from 'spacetime'
let d = spacetime.now()
d.format('nice')
//'Apr 1st, 4:32pm'

Demo     •     Full API

plugins:

Date Inputs:

we can parse all the normal stuff, and some fancy stuff:

//epoch
s = spacetime(1489520157124)

//array [yyyy, m, d] (zero-based months, 1-based days)
s = spacetime([2017, 5, 2])

//iso
s = spacetime('July 2, 2017 5:01:00')

// All inputs accept a timezone, as 2nd param:
s = spacetime(1489520157124, 'Canada/Pacific')
s = spacetime('2019/05/15', 'Canada/Pacific')

// or set the offset right in the date-string (ISO-8601)
s = spacetime('2017-04-03T08:00:00-0700')
// 'Etc/GMT-7'

// Some helpers
s = spacetime.now()
s = spacetime.today() // This morning
s = spacetime.tomorrow() // Tomorrow morning
s = spacetime.min() // the earliest-possible date (271,821 bc)
s = spacetime.max() // the furthest-possible future date (27k years from now)

for fancier natural-language inputs, use compromise-dates.

Get & Set dates:

you can whip things around, but stay intuitive

s.date() // 14
s.year() // 2017
s.season() // Spring
s = s.hour(5) // Change to 5am
s = s.date(15) // Change to the 15th
s = s.day('monday') // Change to (this week's) monday
s = s.month('march') // Change to (this year's) March 1st
s = s.quarter(2) // Change to April 1st
s.era() // 'BC'/'AD'
s.decade() // 2000
s.century() // 21

// Percentage-based information
s.progress().month = 0.23 // We're a quarter way through the month
s.progress().day = 0.48 // Almost noon
s.progress().hour = 0.99 // 59 minutes and 59 seconds

// Add/subtract methods
s = s.add(1, 'week')
s = s.add(3, 'quarters')
s = s.subtract(2, 'months').add(1, 'day')

// start-of/end-of
s = s.startOf('day') // 12:00am
s = s.startOf('month') // 12:00am, April 1st
s = s.endOf('quarter') // 11:59:59pm, June 30th

s = s.nearest('hour') //round up/down to the hour
s = s.nearest('quarter-hour') //5:15, 5:30, 5:45..
s = s.next('month') //start of the next month
s = s.last('year') //start of the last year

// fill-in all dates between a range
s.every('week', 'Jan 1st 2020') // (in tz of starting-date)

//utilities:
s.clone() // Make a copy
s.isValid() // Sept 32nd → false
s.isAwake() // it's between 8am → 10pm
s.json() // get values in every unit as key-val object

if it's 9am on tuesday, and you add a week, it will still be 9am on tuesday. ... even if some crazy changes happen.

Comparisons:

let s = spacetime([2017, 5, 2])
let start = s.subtract(1, 'milliseconds')
let end = s.add(1, 'milliseconds')

// gt/lt/equals
s.isAfter(d) // True
s.isEqual(d) // False
s.isBefore(d) // False
s.isBetween(start, end, inclusive?) // True

// Comparison by unit
s.isSame(d, 'year') // True
s.isSame(d, 'date') // False
s.diff(d, 'day') // 5
s.diff(d, 'month') // 0

//make a human-readable diff
let before = spacetime([2018, 3, 28])
let now = spacetime([2017, 3, 28]) //one year later
now.since(before)
// {diff: { months: 11, days: 30, ...},  rounded: 'in 12 months'  }

all comparisons are done with sensitivity of timezone - 8am EST is < 8am PST.

Timezones:

the best way to describe a timezone is an IANA code:

// Roll into a new timezone, at the same moment
s = s.goto('Australia/Brisbane')

if you want to support relaxed timezone names like 'EST', Eastern time, use timezone-soft

spacetime.extend(require('timezone-soft'))

s = s.goto('milwaukee') // 'America/Chicago'
s = s.goto('-7h') // UTC-7
s = s.goto('GMT+8') // -8h!
// (these should be used with some caution)

play-around with timezones, and their DST-changes:

//list timezones by their current time
spacetime.whereIts('8:30pm', '9:30pm') // ['America/Winnipeg', 'America/Yellowknife'... ]
spacetime.whereIts('9am') //(within this hour)

// Timezone metadata
s.timezone().name // 'Canada/Eastern' (either inferred or explicit)
s.hemisphere() // North
s.timezone().current.offset // -4 (in hours)
s.hasDST() // True
s.isDST() // True

//list all timezones
spacetime.timezones()

you can flip-around the world pretty quick.

spacetime will use your local timezone, by default:

.goto(null) will pluck your current tz safely from your browser or computer.

spacetime().time('4:30pm').goto('Europe/Paris').goto(null).time()
// 4:30pm

Date Formatting:

it's a pretty-sensible process to create nice-looking dates:

// Date + time formatting
s.format('time') // '5:01am'
s.format('numeric-uk') // 02/03/2017
s.format('month') // 'April'
s.format('month-short') // 'Apr'
s.format('month-pad') // '03'
s.format('iso-month') // '04'

//if you want more complex formats, use {}'s
s.format('{year}-{date-pad}-{month-pad}') // '2018-02-02'
s.format("{hour} o'clock") // '2 o'clock'
s.format('{time}{ampm} sharp') // '2:30pm sharp'

//if you prefer, you can also use unix-formatting
s.unixFmt('yyyy.MM.dd h:mm a') // '2017.Nov.16 11:34 AM'

Limitations & caveats

◆ Historical timezone info

DST changes move around all the time, and timezones pop-in and out of existence. We store and use only the latest DST information, and apply it to historical dates.

◆ International date line

.goto() never crosses the date-line. This is mostly the intuitive behaviour.

But if you're in Fiji (just west of the date line), and you go to Midway (just east of the date line), .goto() will subtract a bunch of hours, instead of just adding one.

◆ Destructive changes

if it's 2:30pm and you add a month, it should still be 2:30pm. Some changes are more destructive than others. Many of thse choices are subjective, but also sensible.

◆ 0-based vs 1-based ...

for better or worse we copy the JavaScript spec for 0-based months, and 1-based dates.

ISO-formatting is different, so keep on your toes.

see more considerations and gotchas

Daylight-savings gotchas

We've written in detail about how spacetime handles Daylight-savings changes here

Fall DST changes have an hour that is repeated twice. There are a lot of tricky situations that come from this. Add 10 minutes at 1:55am, and a spacetime diff may show -50mins. Within an hour of this change, some spacetime methods may be off-by-one hour.

Springtime DST changes are generally smoother than Fall ones.

Config:

Ambiguity warnings:

javascript dates use millisecond-epochs, instead of second-epochs, like some other languages. This is a common bug, and spacetime can warn if you set an epoch within January 1970. to enable:

let s = spacetime(123456, 'UTC', {
  silent: false
})
s.log() // "Jan 1st, 12:02am"

There is another situation where you may see a console.warn - if you give it a timezone, but then set a ISO-date string with a different offset, like 2017-04-03T08:00:00-0700 (-7hrs UTC offset). It sets the timezone to UTC-7, but also gives a warning.

let s = spacetime('2017-04-03T08:00:00-0700', 'Canada/Eastern', {
  silent: false
})
s.timezone().name // "Etc/GMT-7"

Configure 'today' context:

spacetime makes some assumptions about some string inputs:

// assumes start of month
let s = spacetime('June 1992')
s.date() // 1

// assumes current year
let s = spacetime('June 5th')
s.year() // 2020 (or whatever it is now)

// assumes Jan 1st
let s = spacetime('2030')
s.month() // 'January'

you can configure this assumed date (usually for testing) by passing it in as an option:

let today= {
  month: 3,
  date: 4,
  year: 1996,
}
let s = spacetime('June 5th', null, {today:today})
s.year() // 1996

it also works for spacetime.now(tz, {today:today}) and others.

Extending/Plugins:

you can throw any methods onto the Spacetime class you want, with spacetime.extend():

spacetime.extend({
  isHappyHour: function() {
    return this.hour() === 16
  }
})

let s = spacetime.now('Australia/Adelaide')
s.isHappyHour()
//false

s = s.time('4:30pm')
s.isHappyHour()
//true

DD/MM/YYY interpretation:

by default spacetime uses the American interpretation of ambiguous date formats, like javascript does:

spacetime('12/01/2018') //dec 1st

// unless it's clear (>12):
spacetime('13/01/2018') //jan 13th

you can change this behaviour by passing in a dmy option, like this:

spacetime('12/01/2018', null, { dmy: true }) //jan 12th

this format is more common in britain, and south america.

Custom languages:

a.i18n({
  days: {
    long: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
    short: ['dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb']
  },
  months: {
    long: [...],
    short: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sep', 'oct', 'nov', 'dic'],
  },
  useTitleCase: true // automatically in .format()
});
a.format('day') //'Sábado'

Configure start of week:

by default, the start of the week is monday.

You can determine the week by the official country setting, with spacetime-week

let s = spacetime.now()
s = s.weekStart('sunday')

s = s.startOf('week')
s.dayName()
//sunday

s = s.endOf('week')
s.dayName()
//saturday

See also:

thank you to the amazing timeanddate.com

Apache 2.0

Comments
  • [Feature] Unix formatting

    [Feature] Unix formatting

    There are many cases where allowing unix style formats would let this library be used in many more places than it can be today. I myself have many cases where the list of included formats do not expose nearly enough flexibility or control to get the exact format needed.

    Would you consider adding a new method (or extending the current one) such as .formatUnix() or something? It could also possibly be a secondary optional package to include which will extend spacetime with the unix formatting capability.

    Background This (and the lack of i18n support) is preventing me from adopting this library over moment which I desperately want to move on from for many reasons. This looks to be the first viable competitor because of the excellent timezone support (and all of my use-cases don't need the historical accuracy!)

    Exposing this functionality (even as an optional module) I am sure would be useful for many others as well in the same situation as I am. There are many cases where legacy processes or database operations require an exact, specific format.

    enhancement 
    opened by pbarbiero 16
  • ES Modules + .mjs

    ES Modules + .mjs

    Hi there!! This is really neat! I was wondering if any of us at webpack could help ship this code over using ES Module Syntax?

    Can include motivations if needed! 👨‍🔬🔥

    hmm 
    opened by TheLarkInn 15
  • Typescript import issue in 6.4.x

    Typescript import issue in 6.4.x

    I'm getting the following error when I try to run my app after upversioning to 6.4.x

    6.3.0 works fine.

    TypeError: (0 , _spacetime2.default) is not a function
    formatDate
    src/utils/date.js:95
      92 |       dateFormat = format;
      93 |   }
      94 | 
    > 95 |   return spacetime(dateValue, TIMEZONE).unixFmt(dateFormat);
      96 | }
      97 | 
      98 | export function getNextStatementDate() {
    

    have tried importing like import spacetime from 'spacetime'; and import { spacetime } from 'spacetime';

    have tried a clean wipe of my repo, fresh install with 6.4.x to no avail. Logging spacetime() gives me /static/media/spacetime.edf1835b.mjs which makes me think it might be a webpack compatibility issue. Running [email protected]

    hmm 
    opened by conroysj 12
  • given iso offset is coerced by dst-offset

    given iso offset is coerced by dst-offset

    image 1

    Hey, bumped into another issue with parsing ISO timestamps. In this case, I am trying to parse 2019-03-13T18:00:00.000-05:00 which is in CST or GMT-6 during DST which is in UTC-5. From the screenshot, I am just parsing the ISO timestamp and outputting it in ISO format and it is converting the offset to -4:00 while keeping the time the same.

    I would really appreciate it if this and Issue 101 could be pushed into a release build. Thanks!

    bug priority fixed-on-dev 
    opened by davyuu 11
  • Spacetime appears to ignore timezone when parsing ISO times

    Spacetime appears to ignore timezone when parsing ISO times

    const timestamp = '2017-04-03T08:00:00-0700'
    const s = spacetime(timestamp)
    const date = new Date(timestamp)
    
    s.timezone().name
    // "Europe/London"
    
    s.hour()
    // 8 
    
    date.getUTCHours()
    // 15 
    

    Unless I'm missing something in how spacetime is supposed to be used, I can't see a way of telling the library that a) the date was in a different timezone to me or b) to somehow localize the datetime I gave it.

    It appears here that you match for a timezone but then don't do anything with it (it would be arr[5]).

    I'm happy to put in a PR but I wanted to check I wasn't misunderstanding what this library is supposed to do.

    opened by samtgarson 11
  • [Feature] Extend `since` with `abbreviated`

    [Feature] Extend `since` with `abbreviated`

    This pr extends the return of the since method with a new string prop abbreviated following the pattern 1y2m3d4m5s. I've found myself doing it enough times that I think it's a worthy addition.

    I realize that m for month and minute can be ambiguous, but I think most if not all of the time it should be contextually apparent.

    abbreviated also deviates from the other properties in that it is always positive regardless of relativity, it's open to discussion but I think it makes sense in context.

    I've extended all tests and ensured they pass, and updated the Since type. I didn't update the readme because it already only covers two of the existing returns types.

    opened by Nfinished 10
  • PST to PDT is off by one day

    PST to PDT is off by one day

    Hello all.

    I have a method that converts UTC to a dynamic local time but testing using America/Los_Angeles the library seems to be off by one day when PST goes over to PDT (winter to summer time)

    According to timeanddate.com/time/zone/usa/los-angeles the time change should occur 2018-03-11 02:00:00 but this seems to happen 2018-03-12 02:00:00 local time.

    Code

    
    // From config config.TIME.FORMAT.RAW_DATE_UNIX_LOCAL
    RAW_DATE_UNIX_LOCAL: 'YYYY-MM-dd HH:mm:ss'
    
    /**
     * Converts from UTC to naive time - timezone aware
     * @param {string} date
     */
    function _dateUTCToLocal (date) {
        // Display as local time
        const s =
            spacetime(date)
            .goto(store.getters.getUser.facility.timezone)
    
        console.log('BEFORE', date, 'AFTER', s.format(config.TIME.FORMAT.RAW_DATE_UNIX_LOCAL))
    
        // Display as local time
        return s.format(config.TIME.FORMAT.RAW_DATE_UNIX_LOCAL)
    }
    
    

    console.log output

    BEFORE 2018-03-12T07:00:00+00:00 AFTER 2018-03-11 23:00:00
    BEFORE 2018-03-12T08:00:00+00:00 AFTER 2018-03-12 00:00:00
    BEFORE 2018-03-12T09:00:00+00:00 AFTER 2018-03-12 01:00:00
    BEFORE 2018-03-12T10:00:00+00:00 AFTER 2018-03-12 03:00:00
    BEFORE 2018-03-12T11:00:00+00:00 AFTER 2018-03-12 04:00:00
    BEFORE 2018-03-12T12:00:00+00:00 AFTER 2018-03-12 05:00:00
    

    Thanks in advance. Love the project!

    next-release 
    opened by ricardobanegas 10
  • Leading zero in miliseconds field is ignored when parsing a string

    Leading zero in miliseconds field is ignored when parsing a string

    λ node
    Welcome to Node.js v15.14.0.
    Type ".help" for more information.
    > const spacetime = require("spacetime");
    > spacetime('2021-11-02T19:55:30.087772+01').format("iso");
    '2021-11-02T19:55:30.877+01:00'
    
    bug ready fixed-on-dev 
    opened by wokalski 9
  • Fractional Timezone Support

    Fractional Timezone Support

    It looks like Spacetime has a bit of trouble with fractional timezones, and gets a bit confused with reading in timezones that are ahead / behind GMT. Example:

    
    // Create a starting place (noon today GMT)
    s = spacetime('2018-08-28T12:00:00Z')
    
    // Setup some timezones to look at
    let timezones = [
      {
        timezone: 'America/Toronto',  // -4h
      },
      {
        timezone: 'Asia/Muscat', // +4h
      },
      {
        timezone: 'Asia/Kathmandu', // +5h 45m
      },
      {
        timezone: 'Asia/Calcutta', // +5h 30m
      }
    ]
    
    timezones = timezones.map(tz => {
      // Create a version of the above time in this timezone
      thisSpacetime = s.clone().goto(tz.timezone)
      offset = thisSpacetime.timezone().current.offset,
      nice =  thisSpacetime.format('nice')
      iso = thisSpacetime.format('iso')
      
      // Create a (hopefully identical) version of the above timezone
      interpreted = spacetime(iso)
      interpretedOffset = interpreted.epoch ? interpreted.timezone().current.offset : '',
      interpretedIso = interpreted.format('iso')
      interpretedNice = interpreted.format('nice')
    
      return {
        ...tz,
        offset,
        nice,
        iso,
        interpretedOffset,
        interpretedIso,
        interpretedNice
      }
    })
    
    console.table(timezones)
    
    

    Outputs the following:

    image

    Issues:

    1. The generated ISO timestamps appear to have the timezone backwards - for Toronto, I would expect a timestamp of "2018-08-28T08:00:00.758-04:00", not "2018-08-28T08:00:00.758+04:00"
    2. ST seems to interpret all positive number timezones as negative numbers (see the interpretted timezone of Asia / Muscat differing from the original offset)
    3. The generated ISO dates for Asia/Kathmandu and Asia/Calcutta is not a proper ISO timestamp, and as such can't be accepted as input to spacetime

    I'm willing to chalk some of this up to my inexperience with the lib / confusion with timezones.

    bug next-release 
    opened by stabback 9
  • outdated timezones

    outdated timezones

    upstream from https://github.com/spencermountain/timezone-soft/issues/9

    the current zonefile and aliases are out of date, america/argentina/cordoba is canonical and doesn't exist on zonefile or backwards.json

    opened by mchangrh 8
  • typescript: import spacetime from ('spacetime') says undefined

    typescript: import spacetime from ('spacetime') says undefined

    I'm relatively new to typescript by my other dependencies are working ok. I have the following error when using this module import method

    image

    but no error when using this method image

    my tslinter is complaining about the 2nd one but other than that it is working. something you may want to look into, not sure if it's specific to me

    fixed-on-dev 
    opened by avishaan 8
  • [Typescript] Could not find declaration file for module 'spacetime'

    [Typescript] Could not find declaration file for module 'spacetime'

    Could not find declaration file for module 'spacetime' when using moduleResolution: 'NodeNext' or "Node16".

    TS version: 4.9.3 Spacetime version: 7.2.0

    hmm 
    opened by abetoots 1
  • How to get tzdb version?

    How to get tzdb version?

    Is there a way to get the current tzdb version used by the library so I can store that along my dates, so that in case something changes I can just do the adjustments?

    enhancement next-release 
    opened by michaelstewarti 1
  • Short Timezone Name in Formatter

    Short Timezone Name in Formatter

    The {timezone} format only returns location names like America/Chicago. Can we get a {timezone-short} that returns the timezone acronym, ie CST? Or is it already available?

    enhancement yess 
    opened by timsayshey 2
  • Rounding up .diff

    Rounding up .diff

    I cant seem to find a way to do this, so I assume that currently it is impossible?

    If so, it would be great to have this as a function.

    Using this library to calculate penalty times by the hour, so it would be nice to have a round up function!

    enhancement 
    opened by owen95t 2
  • Future DST changes incorrect for Europe/London

    Future DST changes incorrect for Europe/London

    Apologies if this is effectively a duplicate of other outstanding timezone-related issues.

    At the moment, if we ask what the UTC equivalent of 2023-03-26 17:00 in Europe/London is, Spacetime tells us that it's 17:00:

    console.log(spacetime('2023-03-26 17:00', 'Europe/London').format('iso-utc'))
    // outputs 2023-03-26T17:00:00.000Z
    

    Whereas we know that in 2023 the DST change will have already taken place at 01:00 that morning, so the correct output would be 2023-03-26T16:00:00.000Z.

    Is this because zonefile/iana.js is currently only storing a single year's worth of DST changes per timezone?

    If so, this is a big problem for regions where the DST change occurs on a different day of month each year. Here in the UK it's the last Sunday of March. It means we can't deal accurately with dates/times from anything other than the current year. If there's a plan for how to solve this, I may be able to put some time towards it.

    enhancement next-release yess 
    opened by coatesap 2
  • DST date folk patterns

    DST date folk patterns

    Yesterday, the clocks went forward 1 hour in the UK. The tomorrow function now moves to the Europe/London timezone incorrectly:

    • spacetime.today().goto("Europe/London").d returns 2022-03-28T00:00:00.000Z (correct)
    • spacetime.tomorrow().goto("Europe/London").d returns 2022-03-29T01:00:00.000Z (incorrect)

    I am using version 6.15.1, so please accept my apologies if this issue has already been fixed. If not, then to ensure you understand when the clocks change in the UK, I have copied the following from the UK government's website (https://www.gov.uk/when-do-the-clocks-change):

    In the UK the clocks go forward 1 hour at 1am on the last Sunday in March (yesterday), and back 1 hour at 2am on the last Sunday in October.

    The period when the clocks are 1 hour ahead is called British Summer Time (BST). There’s more daylight in the evenings and less in the mornings (sometimes called Daylight Saving Time).

    When the clocks go back, the UK is on Greenwich Mean Time (GMT).

    enhancement help wanted yess 
    opened by thomasdowell 1
Releases(7.4.0)
  • 7.4.0(Dec 30, 2022)

    • [update] - 2023 DST changes for mexico
    • [update] - 2023 DST changes for jordan
    • [update] - 2023 DST changes for fiji
    • [update] - missing seconds, quarters methods #360 #359
    • [new] - {AMPM} uppercase fmt
    Source code(tar.gz)
    Source code(zip)
  • 7.3.0(Dec 8, 2022)

  • 7.2.0(Sep 13, 2022)

    • [update] - timezone aliases
      • Kiev/Kyiv alias
      • alias redundancies in indiana/kentucky,north_dakota
      • alias redundancies for volgograd
      • alias redundancies for coral harbour and santa_isabel
      • alias redundancies for katmandu kathmandu
    • [update] - dst changes
      • chile (last minute) DST change
      • antarctic dst times
      • fix yukon dst
    • update dependencies
    Source code(tar.gz)
    Source code(zip)
  • 7.1.4(Apr 18, 2022)

  • 7.1.3(Apr 11, 2022)

  • 7.1.2(Feb 28, 2022)

  • 7.1.1(Feb 27, 2022)

    • [new] - support custom i18n strings for am/pm
    • [new] - more alias support for deprecated iana codes
    • [fix] - for silent/verbose mode
    • update deps
    Source code(tar.gz)
    Source code(zip)
  • 7.1.0(Jan 12, 2022)

  • 7.0.2(Jan 6, 2022)

  • 7.0.1(Jan 6, 2022)

  • 7.0.0(Jan 5, 2022)

    7.0.0 [Jan 2022]

    • [change] - update to 2022 DST dates
    • [change] - return 'Sep' instead of 'Sept' in format('month-short') and 'MMM' #304
    • [change] - convert to ES-modules, + exports fields
    • [change] - make .every() results inclusive of start
    • [change] - alias old IANA codes to contemporary ones
    • [change] - move cal plugin to repo spencermountain/scal
    • [new] - add ISO duration to .since() results (thanks Adam)
    • [fix] - iso-parsing issues #320
    • [fix] - typescript issue #305
    • [fix] - subtract months issue #312
    • [fix] - unix 'yy' format issue #302
    • [change] - return 'Etc/GMT' not 'Etc/GMT+0'
    • [change] - update deps
    • bump + republish plugins
    Source code(tar.gz)
    Source code(zip)
  • 6.16.3(Aug 6, 2021)

    • [new] - .daysInMonth() method (thanks m1212e!)
    • [change] - replace deprecated timezone aliases (thanks Michael!)
    • [change] - date/day naming inconsistency in add method (thanks Andy!)
    • [fix] - typescript fixes (thanks Adam!)
    • [fix] - many-year add issue #235
    • [fix] - iso format year-padding for BC years
    • update deps
    Source code(tar.gz)
    Source code(zip)
  • 6.16.2(Jun 14, 2021)

  • 6.16.1(May 11, 2021)

  • 6.16.0(Apr 15, 2021)

    • [change] - improvements to date-sting parsers
    • [change] - drop ie11 polyfills in min.js build
    • [change] - minify and stop compiling esm build
    Source code(tar.gz)
    Source code(zip)
  • 6.15.2(Apr 13, 2021)

  • 6.15.1(Apr 7, 2021)

  • 6.15.0(Apr 6, 2021)

  • 6.14.0(Mar 18, 2021)

    • [change] - add missing timezones from indiana and argentina
    • [change] - set old timezones as aliases of newer ones
    • [new] - add min, max methods
    • [change] - comment-out tests that were failing in some timezones
    • update deps, and documentation
    Source code(tar.gz)
    Source code(zip)
  • 6.13.1(Mar 5, 2021)

  • 6.13.0(Mar 2, 2021)

    • [change] - support more alt day formats like .day('mo')
    • [change] - allow .week() to return 53
    • [change] - support swapped-parameters for .each()
    • [change] - support swapped-parameters for .isSame()
    • update deps
    Source code(tar.gz)
    Source code(zip)
  • 6.12.5(Feb 10, 2021)

  • 6.12.4(Feb 9, 2021)

  • 6.12.3(Feb 3, 2021)

    • [fix] - fix .every() >= issue
    • [fix] - fix today-passthrough in some date formats
    • [change] - use updated DST changes (171 changes)
    • [change] - support explicit local-timezone (thanks Mitsunee)
    • update deps
    Source code(tar.gz)
    Source code(zip)
  • 6.12.2(Dec 18, 2020)

    • [change] - support explicit local-timezone (thanks Mitsunee)
    • [change] - support i18n titlecase config (thanks Kayla)
    • [fix] - endOf('season') issue
    • [fix] - fix character escaping issue in unixFmt method #207 update deps
    Source code(tar.gz)
    Source code(zip)
  • 6.12.1(Dec 1, 2020)

    • [new] - support for '97 year format
    • [change] - support 13h00 time format
    • [change] - support 09.13.2013 and 13.09.2013 formats
    • [fix] - .add() issue sometimes effecting quarter/season
    Source code(tar.gz)
    Source code(zip)
  • 6.12.0(Dec 1, 2020)

    • [new] - support period-seperated short-iso format
    • [new] - support fortnight in add/remove methods
    • [new] - support 'tues' 'thurs' in day() method
    • [new] - support '2002-06' truncated iso input
    Source code(tar.gz)
    Source code(zip)
  • 6.11.0(Nov 26, 2020)

    • [change] - support 6-digit millisecond, and lowercase iso
    • [change] - first week of year must start > dec 29th
    • [fix] - typescript fixes
    • update deps
    Source code(tar.gz)
    Source code(zip)
  • 6.10.1(Nov 20, 2020)

  • 6.10.0(Nov 14, 2020)

    • [fix] - support whitespace between time and am/pm (thanks Andy!)
    • [change] - make empty array + obj equal to null inputs #240
    • [change] - update timezones
    • [change] - remove Yukon DST preemptively
    Source code(tar.gz)
    Source code(zip)
Owner
spencer kelly
freelance javascripter, believer in the internet
spencer kelly
Timezone support for moment.js

Moment Timezone IANA Time zone support for Moment.js Project Status Moment-Timezone is an add-on for Moment.js. Both are considered legacy projects, n

Moment.js 3.7k Jan 1, 2023
⚡️ Fast parsing, formatting and timezone manipulations for dates

node-cctz CCTZ is a C++ library for translating between absolute and civil times using the rules of a time zone. Install You will need C++11 compatibl

Vsevolod Strukchinsky 59 Oct 3, 2022
lightweight, powerful javascript datetimepicker with no dependencies

flatpickr - javascript datetime picker Motivation Almost every large SPA or project involves date and time input. Browser's native implementations of

flatpickr 15.4k Jan 3, 2023
A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS

Pikaday A refreshing JavaScript Datepicker Lightweight (less than 5kb minified and gzipped) No dependencies (but plays well with Moment.js) Modular CS

null 7.9k Jan 4, 2023
lightweight, powerful javascript datetimepicker with no dependencies

flatpickr - javascript datetime picker Motivation Almost every large SPA or project involves date and time input. Browser's native implementations of

flatpickr 15.4k Jan 9, 2023
Lightweight and simple JS date formatting and parsing

fecha Lightweight date formatting and parsing (~2KB). Meant to replace parsing and formatting functionality of moment.js. NPM npm install fecha --save

Taylor Hakes 2k Jan 5, 2023
A lightweight, locale aware formatter for strings containing unicode date tokens.

Date Token Format A lightweight (~2kB), locale aware formatter for strings containing unicode date tokens. Usage Install the package using: yarn add d

Donovan Hutchinson 1 Dec 24, 2021
⏳ Modern JavaScript date utility library ⌛️

date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js. ?? Documentation

date-fns 30.6k Dec 29, 2022
🕑 js-joda is an immutable date and time library for JavaScript.

js-joda is an immutable date and time library for JavaScript. It provides a simple, domain-driven and clean API based on the ISO8601 calendar.

null 1.5k Dec 27, 2022
⏰ Day.js 2KB immutable date-time library alternative to Moment.js with the same modern API

English | 简体中文 | 日本語 | Português Brasileiro | 한국어 | Español (España) | Русский Fast 2kB alternative to Moment.js with the same modern API Day.js is a

null 41.7k Dec 28, 2022
An easily internationalizable, mobile-friendly datepicker library for the web

react-dates An easily internationalizable, accessible, mobile-friendly datepicker library for the web. Live Playground For examples of the datepicker

Airbnb 12k Jan 6, 2023
⏱ A library for working with dates and times in JS

Luxon Luxon is a library for working with dates and times in JavaScript. DateTime.now().setZone("America/New_York").minus({ weeks: 1 }).endOf("day").t

Moment.js 13.4k Jan 9, 2023
:clock8: :hourglass: timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement.

timeago.js timeago.js is a nano library(less than 2 kb) used to format datetime with *** time ago statement. eg: '3 hours ago'. i18n supported. Time a

hustcc 4.9k Jan 4, 2023
CalendarPickerJS - A minimalistic and modern date-picker component/library 🗓️👨🏽‍💻 Written in Vanilla JS

CalendarPickerJS The simple and pretty way to let a user select a day! Supports all major browser. Entirely written in Vanilla JavaScript with no depe

Mathias Picker 15 Dec 6, 2022
⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API

English | 简体中文 | 日本語 | Português Brasileiro | 한국어 | Español (España) | Русский Fast 2kB alternative to Moment.js with the same modern API Day.js is a

null 41.7k Dec 28, 2022
This library provide a fast and easy way to work with date.

Calendar.js Calendar.js provide a fast way to work with dates when you don't wanna deal with hours, minute, second and so on. It means that Calendar.j

ActuallyNotaDev 3 Apr 27, 2022
Parse, validate, manipulate, and display dates in javascript.

Moment.js A JavaScript date library for parsing, validating, manipulating, and formatting dates. Project Status Moment.js is a legacy project, now in

Moment.js 47.1k Jan 2, 2023
🍞📅A JavaScript calendar that has everything you need.

A JavaScript schedule calendar that is full featured. Now your service just got the customizable calendar. ?? Table of Contents Collect statistics on

NHN 10.4k Jan 3, 2023
TheDatepicker - Pure JavaScript Datepicker 📅

Pure JavaScript Datepicker by Slevomat.cz.

The Datepicker 27 Dec 16, 2022