mattbradley / livestampjs

A simple, unobtrusive jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements using Moment.js.
http://mattbradley.github.com/livestampjs
MIT License
409 stars 70 forks source link

Annoying moment.js deprecation warning #25

Open dandv opened 10 years ago

dandv commented 10 years ago

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?

elgrafico commented 10 years ago

+1

hgtesta commented 10 years ago

+1

philfreo commented 9 years ago

:+1:

mattbradley commented 9 years ago

Will fix in v2.0.

KrunchMuffin commented 9 years ago

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.

onedr0p commented 8 years ago

So long to change this simple fix!

+1

manifestinteractive commented 8 years ago

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.