strftime-format
v1.0.3
Published
Takes a Date object and a string argument and replaces all strftime C-type time variables in the string with the corresponding data from the Date object.
Downloads
92
Readme
strftime-format
Takes in a Date object and a string and replaces all strftime C-type time variables in the string with the corresponding data from the Date object.
Installation
yarn add strftime-format
Syntax
strftimeFormat(date, string);
strftimeFormat(date, string, locale);
Parameters
date
A Date object
string
A string containing strftime C-type time variables. List of supported variables here: https://strftime.org/
locale
(optional)
A locale string
Example
import strftimeFormat from 'strftime-format';
const date = new Date();
const dateString = strftimeFormat(date, '%A %-d. %B, %Y');
const germanDateString = strftimeFormat(date, '%A %-d. %B, %Y', 'de-DE');