javascript - Calculate Time since MySQL timestamp -


disclaimer: javascript skills limited, , knowledge of javascript standard functions/library. forgive me, if question stupid.
have standard mysql timestamp given , want user see, how time has passed since timestamp.
know there time_diff function, that's generic me, need user-readable solution. preferably "written 34 seconds ago", "written 2 hours ago", "written week ago", "written year ago", "written on 24th december 2005", etc. if there built-in function (or popular library), please let me know...
alone enough, i'd hear suggestions on how write timer updating every time unit (the first minute should update every second, first hour every minute etc.).

another solution found using mysql timestampdiff method, still generic, wouldn't have worry possible time-zone differences. (client in est, server elsewhere).
updating done via ajax requests (probably bad idea when using multiple timestamps) or via manually incrementing given time.

tl;dr need: function formatting time difference user/easy readable format.

any appreciated!

you can convert unix timestamp value javascript date object

var date = new date(unix_timestamp*1000); 

then can make use of plugin

http://timeago.yarp.com/

for need count down timer suggest use

http://countdownjs.org/


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -