ts change date format
import { DatePipe } from '@angular/common'
...
constructor(public datepipe: DatePipe){}
...
myFunction(){
this.date=new Date();
let latest_date =this.datepipe.transform(this.date, 'yyyy-MM-dd');
}
ts change date format
import { DatePipe } from '@angular/common'
...
constructor(public datepipe: DatePipe){}
...
myFunction(){
this.date=new Date();
let latest_date =this.datepipe.transform(this.date, 'yyyy-MM-dd');
}
show timestamp as yyyy mm dd html angular
import { DatePipe } from '@angular/common'
...
constructor(public datepipe: DatePipe){}
...
myFunction(){
this.date=new Date();
let latest_date =this.datepipe.transform(this.date, 'yyyy-MM-dd');
}
date format in typescript
#Installation
$ npm install dateformat
#Usage
var dateFormat = require("dateformat");
var now = new Date();
var today = dateFormat(now, "yyyy-mm-dd");
Date format in angular ts
public getAllBookings() {
// Get the dates
const today = new Date();
const tomorrow = new Date(today.setDate(today.getDate() + 1));
return new Promise((resolve, reject) => {
this.http
.get(
`${this.kioskservice.getAPIUrl()}search/dashboard/${this.kioskservice.LocationGUID()}/?apikey=${this.kioskservice.getAPIKey()}&format=json&from=${this.dateFormat(today)}&until=${this.dateFormat(tomorrow)}&full=true`
)
.toPromise()
.then(
res => {
this.config = res.json()
console.log(res.json());
resolve();
},
msg => {
throw new Error("Couldn't get all Bookings: " + msg);
}
);
});
}
// Helper function to format if you don't use moment.js or something alike
private dateFormat(date: Date) {
const day = date && date.getDate() || -1;
const dayWithZero = day.toString().length > 1 ? day : '0' + day;
const month = date && date.getMonth() + 1 || -1;
const monthWithZero = month.toString().length > 1 ? month : '0' + month;
const year = date && date.getFullYear() || -1;
return `${year}-${monthWithZero}-${dayWithZero}`;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us