Giter VIP home page Giter VIP logo

date-expand's Introduction

Expand a date into all the various representations of its constituent components, like 4-digit year, 2-digit year, month, two-digit month and so on. All strftime formats are included, and more. Use when you need serialized dates in logic-less templates.

Install with npm install date-expand.

Usage:

var expandDate = require('date-expand');
var date = new Date()
console.log(expandDate(date));

Or monkey-patch instead:

Object.defineProperty(Date.prototype, 'expand', {value: require('date-expand')});
var date = new Date()
console.log(date.expand());

Both will return an object containing various ways of representing that date:

{ human: 'Tue Sep 02 2014 11:10:51 GMT+0200 (CEST)',
  datetime: '2014-09-02 09:10:51',
  date: '2014-09-02',
  time: '09:10:51',
  clock: '09:10',
  iso: '2014-09-02T09:10:51.299Z',
  year: 2014,
  month: 9,
  day: 3,
  hours: 11,
  minutes: 10,
  seconds: 51,
  milliseconds: 299,
  timestamp: 1409649051299,
  unix: 1409649051,
  offset: -120,
  a: 'Tue',
  A: 'Tuesday',
  b: 'Sep',
  B: 'September',
  c: 'c',
  C: '20',
  d: '02',
  D: '09/02/14',
  e: ' 2',
  F: '2014-09-02',
  g: 'g',
  G: 'G',
  h: 'Sep',
  H: '11',
  I: '11',
  j: '245',
  m: '09',
  M: '10',
  n: '\n',
  p: 'AM',
  r: '11:10:51 AM',
  R: '11:10',
  S: '51',
  t: '\t',
  T: '11:10:51',
  u: '2',
  U: '35',
  V: 'V',
  w: '2',
  W: '35',
  x: 'x',
  X: 'X',
  y: '14',
  Y: '2014',
  z: '+0200',
  Z: 'CEST' }

date-expand's People

Contributors

debrouwere avatar

Watchers

 avatar  avatar

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.