almoment
TypeScript icon, indicating that this package has built-in type declarations

0.5.8 • Public • Published

Almoment


Lightweight moment.js alternative

Installation

npm install almoment

Usage

import { format } from "almoment"
const stringDate = "Sun Aug 07 2021 12:18:37 GMT+0500 (Uzbekistan Standard Time)"
const formattedDate = format(stringDate, "DD-MM-YYYY")
console.log(formattedDate)
// Output: 07-08-2021

const formattedTime = format(stringDate, "hh:mm:ss")
console.log(formattedTime)
// Output: 12:18:37

const mixedFormat = format(stringDate, "hh:mm/ss YYYY/MM/DD")
console.log(mixedFormat)
// Output: 12:18/37 2021/08/07

It will replace string with value. Value is always two digit (for example August is not '8' but '08'). If you want single digit, pass single letter (for hours - 'h'). Plus if you want to get last 2 digits of year, pass "YY"

String definition
hh hours (to get single digit -'h', the same for belows)
mm minutes
ss seconds
DD days
MM months
YYYY years (to get last two digits - 'YY')

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i almoment

Weekly Downloads

1

Version

0.5.8

License

MIT

Unpacked Size

6.25 kB

Total Files

4

Last publish

Collaborators

  • algosdev