New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

simple-date

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-date

converts dates so you don't have to.

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
10
Maintainers
1
Weekly downloads
 
Created
Source

simple-date

Simple, versatile Javascript date formatter that can be run in the browser or required as a module in nodejs. Takes a given date string / object and converts it to desired date format.

install

npm install simple-date

format

Takes 2 arguments, the string or date object you have and the desired format you want (in that order).

ex.

var formattedDate = simpleDate.format(your_date, desired_format);

arguments

Currently takes 5 standard date formats as first arguments and 4 desired formats as second arguments:

ex. first args
  • '09-07-1998' - (dashed format)
  • '09/07/1998' - (slashed format)
  • 'September 07, 1998' - (month/day/year format)
  • '07 September, 1998' - (day/month/year format)

or

  • date object
ex. second args
  • 'dashed' - ex. output: 09-07-1998
  • 'slashed' - ex. output: 09/07/1998
  • 'mdy' - ex. output: September 07, 1998
  • 'dmy' - ex. output: 07 September, 1998
in node.js
var simpleDate = require('simple-date');
var current_date = new Date();
var formattedDate = simpleDate.format(current_date, 'dashed');
console.log(formattedDate);   // logs current_date in dashed format: XX-XX-XXXX
in browser
<script src='path/to/simple-date.js'></script>
<script>
    var current_format = '09/07/1998';
    var new_format = simpleDate(current_format, 'mdy');
    console.log(new_format);    // logs: September 07, 1998
</script>

Keywords

simple

FAQs

Package last updated on 25 Feb 2015

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