livestampjs icon indicating copy to clipboard operation
livestampjs copied to clipboard

Annoying moment.js deprecation warning

Open dandv opened this issue 11 years ago • 7 comments

The moment library is moving away from accepting constructors of the form moment(timestamp). A time format must be passed. There are three lines of code that use the old syntax:

https://github.com/mattbradley/livestampjs/blob/master/livestamp.js#L27 https://github.com/mattbradley/livestampjs/blob/master/livestamp.js#L30 https://github.com/mattbradley/livestampjs/blob/master/livestamp.js#L94

timestamp is a string at that point in code, e.g. Tue Aug 05 2014 15:50:37 GMT-0700 (Pacific Daylight Time)", which seems brittle. Could it be the UNIX timetamp in seconds instead, or a Date object?

dandv avatar Aug 05 '14 23:08 dandv

+1

elgrafico avatar Sep 11 '14 14:09 elgrafico

+1

hgtesta avatar Nov 09 '14 18:11 hgtesta

:+1:

philfreo avatar Apr 15 '15 02:04 philfreo

Will fix in v2.0.

mattbradley avatar Apr 24 '15 13:04 mattbradley

This wasn't working for me, had to change Line 19 to be

timestamp = moment.unix(timestamp);

you have to use unix as of 1.6 I am on 2.10.3

UPDATE: If I use UNIX_TIMESTAMP(time) from MySQL, I don't need the unix, but if I convert the date in the application with coldfusion, I do need it.

KrunchMuffin avatar Jul 08 '15 19:07 KrunchMuffin

So long to change this simple fix!

+1

onedr0p avatar Feb 07 '16 22:02 onedr0p

Submitted Pull Request #55 for those that want an easy solution. In short, Moment.js no longer likes dates as strings ... so they need to be converted into an object first. Quick three line change will hopefully get reviewed ASAP :) Until then, you can check out my PR branch for the fix.

manifestinteractive avatar Jun 13 '16 11:06 manifestinteractive