Tempo: The Easiest Way to Work With Dates in JavaScript

Tempo is a new date package designed to be small and is the easiest way to work with dates in JavaScript and TypeScript:

Tempo is a new library in a proud tradition of JavaScript date and time libraries. Inspired by the likes of moment.js, day.js, and date-fns, Tempo is built from the ground up to be as small and easy to use as possible — including first-class support for timezone operations.

It includes a collection of utilities for working with JavaScript’s native Date object, such as format and parse:

import { format, parse } from "@formkit/tempo"

const readable = format(new Date(), "full"); // Sunday, February 18, 2024

parse(readable, "full"); // Date: 2024-02-18T07:00:00.000Z

Tempo comes with a variety of format styles (i.e., full in the previous example) and tokens for formatting dates in any way you might need. You can also find a large number of modifiers and timezone support:

import { addDay, tzDate } from "@formkit/tempo"

// Add 1 day
addDay("2013-03-15"); // 2013-03-16T07:00:00.000Z

// Produces the date for 12 noon Nov 18, 2013 in New York
tzDate("2013-11-18 12:00", "America/New_York")

Tempo looks impressive, offering much of what you'd need to work with dates and has excellent documentation around its functionality; you can get started by reading the docs at tempo.formkit.com. The source code is also available on GitHub at formkit/tempo.


The post Tempo: The Easiest Way to Work With Dates in JavaScript appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

Read more

© 2024 Extly, CB - All rights reserved.