ect-date-formatter-js
v1.21.6
Published
A JavaScript-first date formatter utility library
Maintainers
Readme
EctDateFormatter JS
ect-date-formatter-js is the JavaScript-first equivalent of the Angular date formatter service, with no Angular dependency required at runtime.
Build
npm run build:ect-date-formatter-jsVanilla JS
import { EctDateFormatterJs } from 'ect-date-formatter-js';
const formatter = new EctDateFormatterJs();
const now = new Date();
console.log(formatter.getISO8601DateFormat(now)); // YYYY-MM-DD
console.log(formatter.getISO8601TimeFormat(now)); // HH:mm:ss
console.log(formatter.getISO8601DateAndTimeFormat(now)); // YYYY-MM-DDTHH:mm:ss
console.log(formatter.formatDate(now, 'dd/MM/yyyy'));
console.log(formatter.formatTime(now, 'HH:mm:ss'));React
import { useMemo } from 'react';
import { EctDateFormatterJs } from 'ect-date-formatter-js';
export function FormattedTimestamp({ date }: { date: Date }) {
const formatter = useMemo(() => new EctDateFormatterJs(), []);
return <span>{formatter.formatDate(date, 'dd/MM/yyyy')} {formatter.formatTime(date, 'HH:mm:ss')}</span>;
}API
getISO8601DateFormat(date)getISO8601TimeFormat(date)getISO8601DateAndTimeFormat(date)formatDate(date, format)formatTime(date, format)createEctDateFormatterJs()
Dependencies
- No framework dependency at runtime
Further help
- https://angular-grid.net/
Licence
The licence agreement for this paid component can be found here:
- https://angular-grid.net/assets/licence/licence_agreement.txt
