1.0.1 • Published 1 year ago

date-time-format-js v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

date-time-format-js

javascript formating functions for all types of date and time formats

alt text

🤖 Introduction

There are three functions that take two parameters (date and type)

date is variable type of date type is variable type of string

  • for date only => formatDate(date,type);
  • for time only => formatTime(date,type);
  • for date&time => formatDateAndTime(date,type);

🚨 Tutorial

  • Types for formatDate(date,type); function
TypeOutput
d04
m05
y2024
monApr
monthApril
year-month-day2024-04-04
year/month/day2024/04/04
day-month-year04-04-2024
day/month/year04/04/2024
month-day-year04-05-2024
month-year-day04-2024-04
month/day/year04/04/2024
month/year/day04/2024/04
longThursday, Apr 4, 2024
shortThu, Apr 4, 2024
  • Types for formatTime(date,type); function
TypeOutput
h:m5:34 AM
h:m:s5:34:9 AM
hh:mm05:34 AM
hh:mm:ss7:38:05 AM
  • Types for formatDateAndTime(date,type); function
TypeOutput
generalThu Apr 04 2024 18: 41: 43 GMT +0200(Eastern European Standard Time)
local4/4/2024, 6:47:34 PM
gmtThu, 04 Apr 2024 16:41:43 GMT
utcThu, 04 Apr 2024 16:41:43 GMT
iso2024-04-04T16:41:43.208Z

🤸 Quick Start

  • js
npm install date-time-format-js

🚀 Examples

import { formatDate ,formatTime ,formatDateAndTime } from 'date-time-format-js';

const date = new Date();

console.log(formatDate(date, 'year-month-day')) // 2024-04-04
console.log(formatTime(date, 'h:m:s')) // 5:34:9 AM
console.log(formatDateAndTime(date, 'local')) // 4/4/2024, 6:47:34 PM
1.0.1

1 year ago

1.0.0

1 year ago