Natively Format JavaScript Dates and Times

Elijah Manor digs into Date’s toLocaleDateString() and toLocaleTimeString() methods to format Dates and Times in JavaScript, with respect to a passed locale.

const date = new Date();

// 7/19/2020

const dateOptions = {
  weekday: 'long',
  year: 'numeric',
  month: 'long',
  day: 'numeric',

console.log(date.toLocaleDateString('en-US', dateOptions));
// Sunday, July 19, 2020

  date.toLocaleDateString('fr-FR', {
    month: 'long',
// juillet

Also comes with a short video.

Natively Format JavaScript Dates and Times →

Litepicker Date Range Picker

I like that the daterange needs to be entered in one single input, and that the rendered datepicker is used as a progressive enhancement on top.

Installation per NPM:

npm i litepicker

At its core, usage is really simple:

import Litepicker from 'litepicker';

const picker = new Litepicker({ element: document.getElementById('litepicker') });

Highly configurable too!

Litepicker — Date range picker – lightweight, no dependencies →


react-day-picker is a flexible date picker component for React.

  • no external dependencies
  • select days, ranges, whatever using CSS modifiers
  • ready for localization, even with moment.js
  • customizable style
  • navigable via keyboard, ARIA support

As with every other well-written React component you can easily include this in your own code to – for example – create a DateInput which combines an <input /> and a react-day-picker.

Here’s a screenshot of an example component I created at work, based upon this example:

That’s a <DayPicker /> contained in a <Popover position="bottom" align="left" /> next to an <input type="text" /> contained in a <StreamSettingsForm /> contained in a <Modal /> you see there 😉


Carbon – A simple PHP API extension for DateTime.

$carbon = new Carbon('first day of next week');

if ($carbon->isWeekend()) {
    echo 'Party!';

echo $carbon->addYear()->diffForHumans(); // 'in 1 year'

Carbon is just a class which is designed to be used instead of DateTime. Due to extending DateTime, all DateTime methods are available to users of Carbon. Additionally, it implements a __toString method, allowing users to put it in place of string representations of date and time as well.

Installation possible using Composer, of course:

composer require nesbot/carbon

Carbon →
Carbon – Date and Time the Right Way →

When Twitter thought it was 2015 already and logged everybody out

Today users of Twitter could not log in via OAuth for a few hours. As seen in the screenshot above Twitter was already thinking it was 2015.

Culprit is that Twitter was formatting dates using the ISO-8601 year number. In PHP it’s the difference between using Y and o:

o — ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.

As the current ISO-8601 week number is 1 (due to next Thursday being January 1, 2015) the current week officially is “the first week of 2015”. Therefore the ISO-8601 year number for this week is 2015, and not 2014.

$ php -r "echo date('Y', strtotime('2014-12-29'));"

$ php -r "echo date('o', strtotime('2014-12-29'));"

Ooops 🙂

Remember Apple’s DnD/alarm bug on iOS in January 2013? Same thing.