“Pipe de datte angulaire” Réponses codées

Formats de date angulaire

'short': equivalent to 'M/d/yy, h:mm a' (6/15/15, 9:03 AM).
'medium': equivalent to 'MMM d, y, h:mm:ss a' (Jun 15, 2015, 9:03:01 AM).
'long': equivalent to 'MMMM d, y, h:mm:ss a z' (June 15, 2015 at 9:03:01 AM GMT+1).
'full': equivalent to 'EEEE, MMMM d, y, h:mm:ss a zzzz' (Monday, June 15, 2015 at 9:03:01 AM GMT+01:00).
'shortDate': equivalent to 'M/d/yy' (6/15/15).
'mediumDate': equivalent to 'MMM d, y' (Jun 15, 2015).
'longDate': equivalent to 'MMMM d, y' (June 15, 2015).
'fullDate': equivalent to 'EEEE, MMMM d, y' (Monday, June 15, 2015).
'shortTime': equivalent to 'h:mm a' (9:03 AM).
'mediumTime': equivalent to 'h:mm:ss a' (9:03:01 AM).
'longTime': equivalent to 'h:mm:ss a z' (9:03:01 AM GMT+1).
'fullTime': equivalent to 'h:mm:ss a zzzz' (9:03:01 AM GMT+01:00).
Hobbes

tuyau à date angulaire

// In Angular 
// Html
<p>{{myDate | date: 'dd-MM-yyyy'}}</p>
// Typescript
myDate: Date = new Date();
Concerned Crossbill

tuyau de date angulaire

      
content_copy
      
{{ dateObj | date }}               // output is 'Jun 15, 2015'
{{ dateObj | date:'medium' }}      // output is 'Jun 15, 2015, 9:43:11 PM'
{{ dateObj | date:'shortTime' }}   // output is '9:43 PM'
{{ dateObj | date:'mm:ss' }}       // output is '43:11'
    
Brave Beaver

Pipe de datte angulaire

dateValue | date: 'dd/MM/yyyy'
Unusual Unicorn

tuyau à date angulaire

content_copy
@Component({
 selector: 'date-pipe',
 template: `<div>
   <p>Today is {{today | date}}</p>
   <p>Or if you prefer, {{today | date:'fullDate'}}</p>
   <p>The time is {{today | date:'h:mm a z'}}</p>
 </div>`
})
// Get the current date and time as a date-time value.
export class DatePipeComponent {
  today: number = Date.now();
}
Muddy Mantis

tuyau de datte

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;    }  }}
Dark Dogfish

Réponses similaires à “Pipe de datte angulaire”

Questions similaires à “Pipe de datte angulaire”

Plus de réponses similaires à “Pipe de datte angulaire” dans HTML

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code