npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-time-date

v0.3.7

Published

easy and simple to get date and time

Downloads

2

Readme

simple-time-date

easy and simple to get date and time

Instailation

npm install simple-time-date

Example

setZone(time, zone)

Options:
  • time - Date object
  • zone - string, UTC time zone

Code

  1. ESM
    import {setZone} from 'simple-time-date'
      
    
    const time = new Date()
    console.log(time)                      // 2023-05-28T18:27:37.802Z (+0)
      
    const newTime = setZone(time, '+3')    // or +3, +03, -2, -02
    console.log(newTime)                   // 2023-05-28T21:27:37.802Z (+3)
  2. CommonJS
    const {setZone} = require('simple-time-date')
      
    
    const time = new Date()
    console.log(time)                      // 2023-05-28T18:27:37.802Z (+0)
      
    const newTime = setZone(time, '+3')    // or +3, +03, -2, -02
    console.log(newTime)                   // 2023-05-28T21:27:37.802Z (+3)

setFormat(time, format)

Options:

  • time - Date object
  • zone - string, time format

Time format:

  • Y - years
  • M - months
  • D - days
  • H - hours
  • m - minutes
  • s - seconds
  • S - milliseconds

Code

  1. ESM
    import {setFormat} from 'simple-time-date'
    
    
    const time = new Date()
    console.log(time)                                   // 2023-05-28T18:40:55.932Z
      
    const newTime = setFormat(time, 'Y-M-D H:m:s.S')
    console.log(newTime)                                // 2023-05-28 18:40:55.932
      
    const newTime2 = setFormat(time, 'D.M.Y H:m:s')
    console.log(newTime2)                               // 28.05.2023 18:40:55
  2. CommonJS
    const {setFormat} = require('simple-time-date')
    
    
    const time = new Date()
    console.log(time)                                   // 2023-05-28T18:40:55.932Z
      
    const newTime = setFormat(time, 'Y-M-D H:m:s.S')
    console.log(newTime)                                // 2023-05-28 18:40:55.932
      
    const newTime2 = setFormat(time, 'D.M.Y H:m:s')
    console.log(newTime2)                               // 28.05.2023 18:40:55

DateTime()

Class DateTime(). Constructor accepts an object with optional parameters.

Options

  • format - string, time format. Default: Y.M.D H:m:s
  • zone - string, UTC time zone. Default: 0

Object has methods:

  • now(format) - returns the time elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.
    Used saved format and zone.
    Options:

    • format - string, time format (not required)
  • create(timeString, format) - returns the time.
    Used saved format and zone.
    Options:

    • timeString - string, the standard string representation of a date time string is a simplification of the ISO 8601 calendar date extended format
    • format - string, time format (not required)

Code

  1. ESM
    import {DateTime} from 'simple-time-date'
       
       
    const time = new Date()
    console.log(time)                                       // 2023-05-28T19:41:46.792Z
       
    const time1 = new Date('2023-05-28 19:15')
    console.log(time1)                                      // 2023-05-28T16:15:00.000Z
       
    const time2 = new DateTime()
    console.log(time2.now())                                // 2023.05.28 19:41:46
    console.log(time2.create('2023-05-28 19:15'))           // 2023.05.28 16:15:00
       
    const time3 = new DateTime({format: 'Y-M-D H:m:s.S'})
    console.log(time3.now())                                // 2023-05-28 19:41:46.799
    console.log(time3.create('2023-05-28 19:15'))           // 2023-05-28 16:15:00.000
       
    const time4 = new DateTime({zone: '-5', format: 'D.M.Y H:m:s'})
    console.log(time4.now())                                // 28.05.2023 14:41:46
    console.log(time4.create('2023-05-28 19:15'))           // 28.05.2023 11:15:00
  2. CommonJS
    const {DateTime} = require('simple-time-date')
       
       
    const time = new Date()
    console.log(time)                                       // 2023-05-28T19:41:46.792Z
       
    const time1 = new Date('2023-05-28 19:15')
    console.log(time1)                                      // 2023-05-28T16:15:00.000Z
       
    const time2 = new DateTime()
    console.log(time2.now())                                // 2023.05.28 19:41:46
    console.log(time2.create('2023-05-28 19:15'))           // 2023.05.28 16:15:00
       
    const time3 = new DateTime({format: 'Y-M-D H:m:s.S'})
    console.log(time3.now())                                // 2023-05-28 19:41:46.799
    console.log(time3.create('2023-05-28 19:15'))           // 2023-05-28 16:15:00.000
       
    const time4 = new DateTime({zone: '-5', format: 'D.M.Y H:m:s'})
    console.log(time4.now())                                // 28.05.2023 14:41:46
    console.log(time4.create('2023-05-28 19:15'))           // 28.05.2023 11:15:00