Incorrect time shown on iOS due to British Summer Time (BST)


#1

I have an Ionic App that has been live now for a couple of months on iOS and Android, however now that the clocks have gone forward in the UK by one hour it means the time is incorrect but only on iOS devices. Android shows the correct time and when I debug the App in browser (Chrome) it shows correctly.

I have checked my API and this is returning the correct time: “StartDate”: “2018-03-29T19:00:00”
However in iOS this is being displayed as: 20:00

This is the code that I am using on the HTML page to display the date and time:

 <p>{{job.StartDate | date:'dd/MM/yyyy'}} @ {{ job.StartDate  | date:'HH:mm' }}</p>

#2

I resolved this by creating a new “pipe” that uses moment.js as follows:

@Pipe({
  name: "dateTimeFormat"
})
@Injectable()
export class DateTimeFormatPipe implements PipeTransform {
  transform(date: any, format: string): any {
    if (date) {
      return moment(date).format(format);
    }
  }
}

I then used that within my HTML as follows:

<p>{{job.StartDate | dateTimeFormat:'DD/MM/YYYY'}} @ {{ job.StartDate  | dateTimeFormat:'HH:mm' }}</p>