0.1.8 • Published 2 years ago
string-to-date-convert v0.1.8
StringToDateConvert
This library was generated with Angular CLI version 13.0.0. Purpose of this library is to convert any string format of date into Date Type in input fields. Currently this is a TS based solution.
Code scaffolding
Run npm install string-to-date
to install this library.
How to use
After installation, declare an object of StringToDateService
in constructor of component in which you are using it.
For Example:
TS Example:
constructor(private fb: FormBuilder,
private stringToDate: StringToDateService){
this.createForm();
}
createForm(){
this.form = this.fb.group({
formate: [null]
})
}
testingDates(date, format){
this.form.controls['formate'].setValue(this.stringToDate.stringToDate(date, format));
}
HTML Code:
<form [formGroup] = "form">
<mat-form-field appearance="fill">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker" formControlName="formate" readonly>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</form>
Walkthrough Formats
Currently worked on these formats. 1. ddmmyyy 2. mm/dd/yyyy 3. yyyy-mm-dd 4. dd/mm/yyyy
Further help
To get more help on this library or suggestion please use GitHub page or contact us at theapppotion@gmail.com
.