date-time-helper-x
v1.0.4
Published
A utility library for formatting dates and times in various formats.
Downloads
16
Maintainers
Readme
Date-Time-Helper-X
Date-Time Helper X is a utility library for formatting dates and times in various formats ( Like This DDMMYYYY , MMDDYYYY, YYYYMMDD ) And converts time into 2 formats [ 12, 24 ] .
It provides functions to easily convert and format dates and times according to different requirements.
Installation
You can install Date-Time Helper X via npm:
npm install date-time-helper-x
Documentation - using Date-Time-Helper-X
This package accept 3 parameters
[1] Date Object or Date String
[2] You will Pass Dates only in this format ('MMDDYYY') | ('MMDDYYYY') | ('YYYYMMDD')
[3] Here 2 parameters but you can use only 1 ('12') | ('24') .
Example - 1 With Api
import React from "react";
import { DateTime } from 'date-time-helper-x';
function YourComponent() {
const [yourArrays, setYourArrays] = useState([]) // Your API arrays
return (
<div>
{yourArrays?.map((item, index) =>
<h5>{DateTime(item?.creatAt, "DDMMYYYY", '12')}</h5>
)}
</div>
)
}
export default YourComponent
Example - 2 Date Object
import React from "react";
import { DateTime } from 'date-time-helper-x';
function YourComponent() {
const myDate = new Date(); // Date Object
return (
<div>
<h5>{DateTime(myDate, "DDMMYYYY", '12')}</h5>
<h5>{DateTime(myDate, "DDMMYYYY")}</h5>
<h5>{DateTime(myDate, '12')}</h5> // yoou can use single parameters
</div>
)
}
export default YourComponent
Example - 3 Date String
import React from "react";
import { DateTime } from 'date-time-helper-x';
function YourComponent() {
const myDate = "2019-01-01T00:00:00.000+00:00"; // Date String
return (
<div>
<h5>{DateTime(myDate, "DDMMYYYY", '12')}</h5>
<h5>{DateTime(myDate, "DDMMYYYY")}</h5>
<h5>{DateTime(myDate, '12')}</h5> // yoou can use single parameters
</div>
)
}