Skip to main content

Introduction

@hirishu10/simple-date-time Version License Downloads DocsPassing

Simple and very helpful package to get the Date Time functionality.

Now everyone can create full fletched Clock and Date-Time service using this package hope you like this Thank You 🙂.

Contents

Prerequisites

  • Node.js (version 16 or greater).
  • Yarn (version 1.5 or greater).
  • A fork of the repo (for any contributions).
  • Please read the docs carefully Thanks

Installation

Using npm

npm i @hirishu10/simple-date-time

Using Yarn

yarn add @hirishu10/simple-date-time

Getting Started

Simple and Customized Date-Time Functionality
import {
getCustomDayNameFull,
getCustomDayNameShort,
getCustomMonthNameFull,
getCustomMonthNameShort,
getCustomMonth,
getCustomYear,
getCustomDate,
getCustomHour,
getCustomMinute,
getCustomSecond,
getCustomAmPm,
getCustomFullDateAndTimeWithAmPm,
getCustomFullDateAndTimeWithAmPmIncludingSeconds,
getCustomDTFormatter,
} from "@hirishu10/simple-date-time";
const fullDay = getCustomDayNameFull();
const shortDay = getCustomDayNameShort();
const fullMonth = getCustomMonthNameFull();
const shortMonth = getCustomMonthNameShort();
const month = getCustomMonth();
const year = getCustomYear();
const toDate = getCustomDate();
const hour = getCustomHour();
const minute = getCustomMinute();
const second = getCustomSecond();
const amPm = getCustomAmPm();
const timestampLower = getCustomFullDateAndTimeWithAmPm();
const timestampwithSeconds = getCustomFullDateAndTimeWithAmPmIncludingSeconds();
Done 🙂 you don't need to write any further code to get the Date-Time Functionality just calling the simple function and you can good to go

Overview

📖 Below we provide examples with code how to use!

getCustomDayNameFull();

const fullDay = getCustomDayNameFull();
Output: friday;

getCustomDayNameShort();

const shortDay = getCustomDayNameShort();
Output: fri;

getCustomMonthNameFull();

const fullMonth = getCustomMonthNameFull();
Output: october;

getCustomMonthNameShort();

const shortMonth = getCustomMonthNameShort();
Output: oct;
*New

getCustomMonth();

const month = getCustomMonth();
Output: 10; // month
*New

getCustomYear();

const year = getCustomYear("yy");
Output: 23; // year

getCustomDate();

const toDate = getCustomDate();
Output: 10; // todate

getCustomHour();

const hour = getCustomHour();
Output: 10; // current hour

getCustomMinute();

const minute = getCustomMinute();
Output: 10; // current minute

getCustomSecond();

const second = getCustomSecond();
Output: 10; // current seconds

getCustomAmPm();

const amPm = getCustomAmPm();
Output: am / pm;

getCustomFullDateAndTimeWithAmPm();

const timestampLower = getCustomFullDateAndTimeWithAmPm();
Output: 10 Oct Fri 10:00am

getCustomFullDateAndTimeWithAmPmIncludingSeconds();

const timestampwithSeconds = getCustomFullDateAndTimeWithAmPmIncludingSeconds();
Output: 10 Oct Fri 10:00:00 am
*New
getCustomDTFormatter().format();
  • getCustomDTFormatter(dateValue?) - If you want to use the old date please provide an unix value inside the dateValue.
  • format(formatValue, insertCharacters?) - You have to pass formatValue (Please read the Method and Props table), Note: *add space after each char
  • insertCharacters is totally optional, if you need to provide a character at the end of each formatValue character, you can add it.
  • Example below:
const customTimeStamp = getCustomDTFormatter().format("dt mt yyyy", { dt: "⟆",mt:"⟆" });
Output: 1072023 ; //

Method and Props Configuration

🔧 Below are the props which you can use to customized the date-time behavior.

Method / PropsTypeDescription
Deprecated capsOnFlag
*New
caseFlag
boolean

String
By default False If Provide True then return the String in UpperCase else in LowerCase

lowercase by default, The "u" string will be in uppercase or "p" for proper case, if provided.
Deprecated properCaseFlagbooleanBy default True Providing this the String will return in Proper structure else all in lower case
changeToStringFlagbooleanTotally Optional if you need in String make true the flag else ignore
Deprecated shortOrFullFlagbooleanBy Default False which return the Day, Month in Short else Make True to return in Full
Deprecated lowerOrUpperFlagbooleanBy Default False which return the Day, Month in lowerCase else Make True to return in UpperCase
*New
yearFlag
String"yy" this will return the last two number, "yyyy" this will return full year
*New
timeStampFlag
Stringcondition: "shortForm_upperCase" OR "shortForm_lowerCase" OR "fullForm_upperCase" OR "fullForm_lowerCase"
*New
formatValue
Stringyy ⟆→ year like 23
yyyy ⟆→ year like 2023
M ⟆→ month like jul
Mu ⟆→ month like JUL
Mp ⟆→ month like Jul
MM ⟆→ month like july
MMu ⟆→ month like JULY
MMp ⟆→ month like July
mt ⟆→ month like 7
dt ⟆→ date like 10
d ⟆→ day like thu
du ⟆→ day like THU
dp ⟆→ day like Thu
d ⟆→ day like thursday
ddu ⟆→ day like THURSDAY
ddp ⟆→ day like Thursday
m ⟆→ minute like 10
h ⟆→ hours like 10
s ⟆→ seconds like 10
ap ⟆→ am / pm
apu ⟆→ AM / PM
h:m ⟆→ hour, minute like 10:10
h:m:s ⟆→ hour,minute,second like 10:10:10

Feature Update

We are working on this for improving the package which helps everyone thanks 🙏🏻

Author

Thank You All 🙏🏻

Made with 🖤 by

Author : Rishu Chowdhary

Email : hi.10rishu@gmail.com

License

MIT License 📄

This project is licensed under the MIT License - see the LICENSE.md file for details