1

I have this function with MomentJs

      CreateFormat(date: string, time: string): string {
            let now = moment(date + " " + time, "YYYY-MM-DD H:m:s z").toDate();
            return moment(now, "YYYY-MM-DD H:m:s z").format("HH:mm");
          }

I got this result : 7:39 pm i want to display it like this 19:39

3 Answers 3

1

I highly recommend using momentJs with your Ionic 3 app.Then you won't have any browser specific errors like you have now.

npm install moment

.ts

import moment from 'moment';

let now = moment().format('LLLL');

Update:

 moment("02:00 PM", "h:mm A").format("HH:mm")  // "14:00"
Sign up to request clarification or add additional context in comments.

2 Comments

I got 'invalid date'
Check this moment("02:00 PM", "h:mm A").format("HH:mm") // "14:00"
0

You can do like this ` {{start_timestamp | date:'HH:mm a'}}

Comments

0

in ts file start_timestamp = 1500536460;

print like this in html <p class="timeLabel">{{start_timestamp | date:'YYYY-MM-DD H:m:s z'}}</p>

1 Comment

You can edit your previous answer.No need to put 2 answers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.