Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Angular: Json Iso Datum als String für Input Type Date

05.02.2021 (👁5601)

Angular: Datum als String für Input Type Date

 

In Angular Material + HTML5 kann man ein Input vom Type Date zum automatischen Anzeigen eines Kalender Controls bei Datumswerten verwenden.

Das Input Type=Date wird als String zugewiesen und gelesen

wie hier: "2021-01-20"

 

 

 

Umwandlung JSON / Angular Date zu input Type Date

    //*convert Iso-Date-Time to Javascript Date: 2021-01-20T08:00:00

    this.sDateStartthis.get_Date_String_from_Date(this.dtStart);

 

Umrechnung JSON / Angular Date zu input Type Date

  get_Date_String_from_DatedtDate:Date ) : String {

    //----< get_Date_String_from_Date() >----

    //*convert TypeScript Date: 2021-01-20T08:00:00 to Time-String "08:00"

    let sDateTime : string = dtDate.toString();

    let sDateString = sDateTime.substr(0,sDateTime.indexOf("T"));

    

    return sDate;

    //----</ get_Date_String_from_Date() >----

  }

 

 

Für die Angular->component.html Ausgabe

        <mat-form-field style="width:130px;">

            <mat-label>Date</mat-label>

            <input type="date" name="ctlsDateStart" matInput [(ngModel)]="sDateStart" >

        </mat-form-field>&nbsp;