Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

date-only

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-only

Date objects that JSON.stringify to YYYY-MM-DD

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

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

Useful when you get date-only values from you DB and want to have them as Date objects in your model, but stringify to YYYY-MM-DD for your JSON API consumers.

const DateOnly = require('date-only');

const dateOnly = new DateOnly();
console.log(JSON.stringify(dateOnly)); // "2016-01-07"
console.log(dateOnly.toISOString()); // 2016-01-07

// pass DateOnly instance to Date to convert to normal date
const normalDate = new Date(dateOnly);
console.log(JSON.stringify(normalDate)); // 2016-01-07T12:34:13.769Z

// pass normal date to DateOnly to convert to DateOnly
dateOnly = new DateOnly(normalDate);
console.log(JSON.stringify(dateOnly)); // "2016-01-07"

Keywords

FAQs

Package last updated on 17 Jan 2016

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