Skip to content

ReadableDateTime.js is a small Node.js module that converts and return value from the default JavaScript Date() function into a readable date and time. The module also has methods to convert them into SQL date and date time formats.

Notifications You must be signed in to change notification settings

sunny420x/ReadableDateTime.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

ReadableDateTime.js

ReadableDateTime.js is a small Node.js module that converts a return value from the default JavaScript Date() function into a readable date and time. The module also has methods to convert them into SQL date and date time formats.

Usage:

new ReadableDate().toDateTime({Date Object}, {padding option true/false})

toDateTime (with pad):

new ReadableDate().toDateTime(new Date(), true)

toDateTime (without pad):

new ReadableDate().toDateTime(new Date(), false)

toDate (with pad):

new ReadableDate().toDate(new Date(), true)

toTime:

new ReadableDate().toTime(new Date())

toSQLDateTime:

new ReadableDate().toSQLDateTime(new Date())

toSQLDate:

new ReadableDate().toSQLDate(new Date())

Examples:

const ReadableDate = require('./ReadableDateTime.js')

console.log("toDateTime (with pad): "+new ReadableDate().toDateTime(new Date(), true)) //Result: toDateTime (with pad): 25/07/2024 14:44:13

console.log("toDateTime (without pad): "+new ReadableDate().toDateTime(new Date(), false)) //Result: toDateTime (without pad): 25/7/2024 14:44:13

console.log("toDate (with pad): "+new ReadableDate().toDate(new Date(), true)) //Result: toDate (with pad): 25/07/2024

console.log("toTime: "+new ReadableDate().toTime(new Date())) //Result: toDate (with pad): 14:44:13

console.log("toSQLDateTime: "+new ReadableDate().toSQLDateTime(new Date())) //Result: toSQLDateTime: 2024-07-25 14:44:13

console.log("toSQLDate: "+new ReadableDate().toSQLDate(new Date())) //Result: toSQLDate: 2024-07-25

About

ReadableDateTime.js is a small Node.js module that converts and return value from the default JavaScript Date() function into a readable date and time. The module also has methods to convert them into SQL date and date time formats.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published