Code Monkey home page Code Monkey logo

get-ymd-hms's Introduction

get_ymd_hms_local(
      date: Date,
      options? = {includeFullYear: false}
): YMD_HMS

Returns date as YMD_HMS in local time.

get_ymd_hms_UTC(
      date: Date,
      options? = {includeFullYear: false}
): YMD_HMS

Returns date as YMD_HMS in UTC (same as GMT) time.

These types are part of the public API:

YMD_HMS = {ymd: Y_M_D, hms: H_M_S}

Y_M_D = {y: string, m: string, d: string}

Each string has 2 digits, except: y will have 4 digits if options.includeFullYear
is true.

H_M_S = {h: string, m: string, s: string}

Each string has 2 digits.

Examples

let date = new Date();

get_ymd_hms_UTC(date, {includeFullYear: true});
// -->  {ymd: {y: '2021', m: '02', d: '20'},  hms: {h: '20', m: '30', s: '30'}}
//       (2021, February 20th, 8:30pm and 30 seconds, UTC)

get_ymd_hms_local(date, {includeFullYear: true});
// -->  {ymd: {y: '2021', m: '02', d: '20'},  hms: {h: '13', m: '30', s: '30'}}
//       (2021, February 20th, 1:30pm and 30 seconds, 7 hours behind UTC)

get_ymd_hms_local(date);
// -->  {ymd: {y: '21', m: '02', d: '20'},  hms: {h: '13', m: '30', s: '30'}}

Installation

npm i @writetome51/get-ymd-hms

Loading

import { get_ymd_hms_local, get_ymd_hms_UTC } from '@writetome51/get-ymd-hms';

License

MIT

get-ymd-hms's People

Contributors

writetome51 avatar

Stargazers

 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.