1.0.3 • Published 1 year ago

timestamp-to-string v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Timestamp-to-date Converter

Timestamp-to-Readable-String-Converter npm.io

Description

A timestamp to readable string or timestamp to date converter is a function that takes a timestamp as input and returns a human-readable date string in a specific format (such as "DayName, MonthName Date, Year"). This is useful for presenting timestamps in a more user-friendly way, and can be customized to match a variety of date and time formats.

Installation

npm install timestamp-to-string

Usage

const convert = require('timestamp-to-string')

// Convert timestamp to date

const timestamp = 1614131200
const date = convert.toDate(timestamp, 'YYYYMMDD')
console.log(date) // 2021-02-25
const convert = require('timestamp-to-string')

// Convert timestamp to readable string

const timestamp = 1614131200
const date = convert.now('DDDMMMDDYYYY')
console.log(date) // Friday, February 26, 2021

Options

toDate(timestamp, format)

ParameterTypeDescription
timestampNumberTimestamp to be converted to date.
formatStringFormat of the date to be returned. See format for more information

now(format)

ParameterTypeDescription
formatStringFormat of the date to be returned. See format for more information

toTime(timestamp, format)

ParameterTypeDescription
timestampNumberTimestamp to be converted to time.
formatStringFormat of the time to be returned. See format for more information

To Date Formate

FormatDescription
DDMMYYYY25/02/2021
DDMMYYYYHHmmss25/02/2021 00:00:00
DDDMMMDDYYYYFriday, February 26, 2021
YYYYMMDD2021-02-25
YYYYMMDDHHmmss2021-02-25 00:00:00
no formate07/11/2022

Now Formate

FormatDescription
DDMMYYYY25/02/2021
DDMMYYYYHHmmss25/02/2021 00:00:00
DDDMMMDDYYYYFriday, February 26, 2021
YYYYMMDD2021-02-25
YYYYMMDDHHmmss2021-02-25 00:00:00
no formate07/11/2022

To Time Formate

FormatDescription
HHmm00:00
hhmmss00:00:00
no formate07:11:22

Github Repository

Timestamp To Readable String

Author

Shubham Kumar - Github

1.0.3

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago