1

Correct time in edit mode:

enter image description here

After I click the checkmark it closes and now the time is wrong:

enter image description here

When I add a new time entry my code gets the local time and sets the offset:

var day = new Date();
var offset = day.getTimezoneOffset() * 60000;
this.newUnbilledTime.end = new Date(Date.now() - offset).toISOString();

When I display it in the edit mode my HTML is:

 <ion-datetime name="endTime" displayFormat="h:mm A" pickerFormat="h:mm A" [(ngModel)]="u.end" (ionChange)="calculateHours(u);" placeholder="{{u.end}}"></ion-datetime>

When I am in unedit mode my HTML is is:

 <h2>{{u.end | date: 'hh:mm a'}}</h2>

Any ideas what is going on here? Its removing my offset and I can't figure out why.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Cody
  • 63
  • 7

1 Answers1

0

Answer

Answering my question in case someone runs into this issue.

I followed Mark Hughes answer here: Angular2 date pipe does not work in IE 11 and edge 13/14

I created a new ts file

Time.ts

import { Pipe, PipeTransform } from '@angular/core';
import * as moment from 'moment';

@Pipe({
name: 'datex'
})

export class DatexPipe implements PipeTransform {
transform(value: any, format: string = ""): string {
    // Try and parse the passed value.
    var momentDate = moment(value);

    // If moment didn't understand the value, return it unformatted.
    if (!momentDate.isValid()) return value;

    // Otherwise, return the date formatted as requested.
    return momentDate.format(format);
}
}

It still was giving me the wrong time when I clicked save edit. I ended up changing the var to:

var momentDate = moment.utc(value);

HTML

<h6>{{u.start | datex:'hh:mm a'}}</h6>
Cody
  • 63
  • 7