71597

Typescript Invalid date with Ionic 3 simulator and Firefox

Question:

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

Answer1:

I highly recommend using <a href="http://momentjs.com/docs/#/use-it/typescript/" rel="nofollow"><strong>momentJs</strong></a> with your Ionic 3 app.Then you won't have any browser specific errors like you have now.

<blockquote>

npm install moment

</blockquote>

<em>.ts</em>

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

<strong>Update:</strong>

moment("02:00 PM", "h:mm A").format("HH:mm") // "14:00"

Answer2:

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

Answer3:

in ts file start_timestamp = 1500536460;

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

Recommend

  • C++ store a modified MySQL timestamp as string
  • Pointwise mutual information on text
  • TQSL to reformat records with duplicate data into one record [closed]
  • Fixed Column Headers For ASP.NET Gridview
  • Change md-datepicker ng-model format
  • Couchbase document dates search - DateTime.Now()
  • 0x800a138f - JavaScript runtime error: Unable to get property 'value' of undefined or null
  • one month after start date-joda
  • Firebase Save Notification to DB not working when app is not running
  • how to find the index position of the ARRAY Where NSPredicate pick the value. I use filteredArrayUsi
  • Formatting a TimeSpan to look like a time zone offset
  • How to create list with carousel effect in android
  • Emulate User Activity
  • jQuery random blockquote
  • A simple datepicker in VueJS
  • How many percent of the tweets does twitter sample API give?
  • How to parsing NSDate to RFC 822 always use in English?
  • How to best manage SMTP clients
  • Swift iOS don't recognize GCM library imports?
  • Get localized short date pattern as String?
  • Lock Horizontal View
  • Parse a date string in a specific locale (not timezone!)
  • Declaring variable dynamically in VB.net
  • Exchange data b/w iOS devices using Bluetooth 4.0
  • ActionScript 2 vs ActionScript 3 performance
  • Font Awesome Showing Box instead of Icons
  • To display the title for the current loaction in map in iphone
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • php design question - will a Helper help here?
  • Traverse Array and Display in markup
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Authorize attributes not working in MVC 4
  • Is it possible to post an object from jquery to bottle.py?
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • Python/Django TangoWithDjango Models and Databases
  • How to push additional view controllers onto NavigationController but keep the TabBar?