Coder Social home page Coder Social logo

datetime.js's Introduction

DateTime Script

Customize output for a javascript Date object

Installation

npm install datetime-js

Examples

var DateTime = require('datetime-js')
var dateObj = new Date()

DateTime(dateObj, 'The date is %m-%d-%Y');
//-> The date is 02-14-2014

DateTime(dateObj, 'Time Now: %h:%i %AMPM');
//-> Time Now: 04:45 PM

DateTime(dateObj, 'Today is the %d:o day of %M');
//-> Today is the 25th day of August

JSFiddle Examples


Format options

Month

Format Description Value Examples
%m Month in number 01 - 12
%M Full month name January - December
%M:s Month in shorthand Jan - Dec

Day

Format Description Value Examples
%d Day of the month 01 - 31
%D Day of the week Monday - Sunday
%D:s Day of the week shorthand Mon - Sun
%d:o Day of the month with ordinal suffix 1st 2nd 3rd 4th . . .

Year

Format Description Value Examples
%Y Year in full format 2019
%Y:r Year in Roman numeral format MMXIX
%y Year in shorthand 19

Time

Format Description Value Examples
%h 12-hour format 1 - 12
%H 24-hour format 00 - 23
%i Minutes 0 - 59
%s Seconds 0 - 59
%ampm am/pm lowercase am pm
%AMPM am/pm uppercase AM PM
%AmPm am/pm capitalized Am Pm

datetime.js's People

Contributors

mitzerh avatar

Stargazers

Michael Canlas avatar  avatar

Watchers

James Cloos avatar

Forkers

jarbob

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.