New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

date-to-iso-8601-string

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-to-iso-8601-string

Presents a JavaScript `Date` as a string in [ISO 8601 format](https://www.loc.gov/standards/datetime/iso-tc154-wg5_n0038_iso_wd_8601-1_2016-02-16.pdf), with support for the Extended (`YYYY-MM-DD`) and Basic (`YYYYMMDD`) variants

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

date-to-iso-8601-string

Presents a JavaScript Date as a string in ISO 8601 format, with support for the Extended (YYYY-MM-DD) and Basic (YYYYMMDD) variants.

Note that this module uses the "local date" in the time zone of the machine, rather than the UTC dfate.

This package includes TypeScript types.

Installation

# With npm
npm install --save date-to-iso-8601-string

# With Yarn
yarn add date-to-iso-8601-string

Usage

Presenting a Date using the more common "Extended" (YYYY-MM-DD format)

// You can also import as a CommonJS module using `require`
import { dateToISO8601String } from 'date-to-iso-8601-string';

const date = new Date('2023-01-01');
dateToISO8601String(date);
//=> '2023-01-01'

Presenting a Date using the less common "Basic" (YYYY-MM-DD format)

import { dateToISO8601String, ISO8601DateFormat } from 'date-to-iso-8601-string';

const date = new Date('2023-01-01');
dateToISO8601String(date, ISO8601DateFormat.Basic);
//=> '20230101'

Development

  • This library code in src/ is written with Typescript.
    • You can compile it to native JavaScript module form (dist/esm) and CommonJS form (dist/commonjs) by running npm run build.
    • The code is automatically built before pushing to npm thanks to a prepublish hook.
  • Tests are implemented using Jest.
    • You can run the tests with npm run test.
  • Linting (including code formatting) is enforced with ESLint, augmented by Prettier.
    • You can check your code with npm run lint, and automatically fix many failures with npm run lint-and-fix.

The compilation, testing and build process are automatically run on pushed code using GitHub Actions.

With thanks to:

The following blog posts were very helpful for putting this - my first ever npm package - together!:

Keywords

FAQs

Package last updated on 27 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc