convert-date-format

1.0.9 • Public • Published

General

With this package it is possible to display a date in a given Format.

Only give the date as string, Object or Date() and as second param the output format

Date

Valid Params as:

- String like "15.04.2022" or "15.04.22 15:07:30"
- Object
    - {year: 2022, month: 12, day: 5}
    - {year: 2022, month: 12, day: 5, hour: 15, minutes: 12, second: 11}
- Any Valid Date like new Date()

Format

mask for:

- yyyy = year
- yy = year only last 2 digits
- mm = Month
- dd = Day
- H  = Hour
- i  = Minutes
- s  = Seconds

example

"dd.mm.yyyy" | 15.04.2023
"mm.yyyy" | 12.2023
"yy-mm-dd" 23-12-20
"H:i"   12:30

Delimiter

- It is your choice which delitmeter you want to use place it into the Format string

Import

Use the following command to import:

import dateFormat from 'convert-date-format/index'

Use

Use Import the following command to paste:

return dateFormat(new Date(),"yyyy-mm-dd H:i:s")
return dateFormat("12.05.2022 15:00:25","yyyy-mm-dd H:i:s")
return dateFormat({"year": 2022, "month": 3, "day":15 },"yyyy-mm-dd H:i:s")
return dateFormat({"year": 2022, "month": 3, "day":15, "hour": 14, "minutes": 25, "second": 35 },"yyyy-mm-dd H:i:s")


"invalid for full date you have give all params like above"
return dateFormat({"year": 2022, "month": 3, "day":15, "hour": 14, "minutes": 25 },"yyyy-mm-dd H:i:s"))

Package Sidebar

Install

npm i convert-date-format

Weekly Downloads

15

Version

1.0.9

License

MIT

Unpacked Size

4.86 kB

Total Files

9

Last publish

Collaborators

  • wum_solution_ug