Date pipe in Angular
{{ date_value | date :'short'}} // 6/15/19, 5:24 PM
Date pipe in Angular
{{ date_value | date :'short'}} // 6/15/19, 5:24 PM
date pipe
import { Pipe, PipeTransform } from '@angular/core';@Pipe({ name: 'dateCount'})export class DateCountPipe implements PipeTransform { transform(value: any): number { let today:Date = new Date(); //get current date and time let todayWithNoTime:any = new Date(today.getFullYear(), today.getMonth(), today.getDate()) var dateDifference = Math.abs(value - todayWithNoTime) //returns value in miliseconds const secondsInDay = 86400; //60 seconds * 60 minutes in an hour * 24 hours in a day var dateDifferenceSeconds = dateDifference*0.001; //converts miliseconds to seconds var dateCounter = dateDifferenceSeconds/secondsInDay; if (dateCounter >= 1 && value > todayWithNoTime){ return dateCounter; }else{ return 0; } }}
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