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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hearty-datetime-helper

v1.1.1

Published

Hearty datetime helper is a small library that can provide small helper functions useful for date and time.

Readme

hearty-datetime-helper NPM version

Hearty datetime helper is a small library that can provide small helper functions useful for date and time.getMonthNameWithOrdinal, strToDate, isToday, daysdiff, etc,.

Installation

npm i hearty-datetime-helper

Usage

var heartyDateTimeHelper = require('heartyDateTimehelper')

getMonthNameWithOrdinal

Return the Month name for given ordinal


    var input = 6
    
    heartyDateTimeHelper.getMonthNameWithOrdinal(input)
    Output: "June"

strToDate

Returns the date in the given valid format (Please provide valid input date) & if no output format is provided, output will return in default date format support input formats : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd


    var input = ('21/10/2018','yyyy-mm-dd')

    heartyDateTimeHelper.strToDate(input)
    Output: "2018-10-21"

isToday

If we provided valid date in supported format, it will return true or false if the input is today support input formats : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd || new Date()


    var input = '21-10-2018'

    heartyDateTimeHelper.isToday(input)
    Output: false

daysdiffFromToday

Takes the input of valid date, it return days difference from input date & today's date support input formats : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd || new Date()


    var input = '28/10/2018'

    heartyDateTimeHelper.daysdiffFromToday(input)
    Output: 5        

daysdiff

Returns difference between dates you provided, If we provide today date also like 'new Date()', It will convert to same format will return the result support input formats : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd


    var input = (new Date(), '2018-11-22')
 
    heartyDateTimeHelper.daysdiff(input)
    Output: 21      

formatMinutes

Returns the number of minutes in HH:MM format from the given input


    var input = 1760
 
    heartyDateTimeHelper.formatMinutes(input)
    Output: "29:20 hrs"     

handleDisplayDigit

If the given input is less than 10, it will append 0 before the number


    var input = 4
 
    heartyDateTimeHelper.handleDisplayDigit(input)
    Output: 04    

getDuration

It will return the duration in the form of object. It will return years, months, days, hours, minutes and seconds.


    var input = ('22/10/2018', '28/11/2018')
 
    heartyDateTimeHelper.getDuration(input)
    Output: { day: "06", displayDiff: "01mo 06d", duration: 3196800, hour: "00", minute: "00", month: "01", second: "00", year: "00"}   

displayDate

It will return the date in string format, such as "Mon, 22 Oct". If we mention year parameter true, It will add year also output. support input formats : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd


    var input = '22/10/2018'
 
    heartyDateTimeHelper.displayDate(input)
    Output: "Mon, 22 Oct 2018"  

getDayFromDate

It will return the day name from given date. support input formats : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd


    var input = '22/10/2016'
 
    heartyDateTimeHelper.getDayFromDate(input)
    Output: "Sat"

getMonthFromDate

It will return the day name from given date. support input formats : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd


    var input = '22/10/2016'
 
    heartyDateTimeHelper.getDayFromDate(input)
    Output: "Sat"

isPastDate

It will return true if provided date is past date or will return false if it's not support input formats : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd


    var input = '22-10-2020'
 
    heartyDateTimeHelper.isPastDate(input)
    Output: false

formatDate

It will return formated date to provided format from the input date support patterns : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd


    var input = ('22/10/2016', 'yyyy/mm/dd')
 
    heartyDateTimeHelper.formatDate(input)
    Output: "2016/10/22"

getDaysAhead

It will return the date days ahead of given date with the provided format. support patterns : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd || new Date()


    var input = ('22/10/2016', 20, 'yyyy/mm/dd')
 
    heartyDateTimeHelper.getDaysAhead(input)
    Output: "2016/11/11"

numberOfDays

It will return the number of days present in given month of given year


    var input = (2, 2012)
 
    heartyDateTimeHelper.numberOfDays(input)
    Output: 29

getDaysBehind

It will return the date days behind of given date with the provided format.


    var input = ('22/10/2016', 20, 'yyyy/mm/dd')
 
    heartyDateTimeHelper.getDaysBehind(input)
    Output: "02-10-2016"

isDateInBetween

It will return if the given date is between provided date limits support patterns : dd/mm/yyyy || dd-mm-yyyy || yyyy/mm/dd || yyyy-mm-dd || new Date()


    var input = ('20/03/2018', new Date(), '21/06/2018')
 
    heartyDateTimeHelper.isDateInBetween(input)
    Output: true

getDateWithOrdinal

It will return date value with ordinal if we provide number as input


    var input = 23
 
    heartyDateTimeHelper.getDateWithOrdinal(input)
    Output: '23rd'

getDateFromTimeStamp

It will return the converted date from given Unix epoch time input


    var input = 1541658537
 
    heartyDateTimeHelper.getDateFromTimeStamp(input)
    Output: "8th Nov, 2018"

getConvertedEpochdate

It will return the converted Unix epoch time date from given Unix epoch time input


    var input = 1541658537
 
    heartyDateTimeHelper.getConvertedEpochdate(input)
    Output: 1541658537000

getTodaydate

It will return today's date in dd/mm/yyyy format


    no input
 
    heartyDateTimeHelper.getTodaydate(input)
    Output: "08/11/2018"