javascript - How to set warnings when time is almost up on DateTime -


i have due_dates column in db , datetime format. want rails app able detect when there day left or hour left etc. based on datetime value. every request have due date each datetime unique. know how make notifications don't know how make timer aspect or you're suppose detect these datetimes before or when pass date.

ex.
today <-- 11/5/2016 |(one day)| 11/6/2016 <--duedate db update/ send notification "one day left"

if want know whether before or duedate

if datetime.now <= duedate     # end 

to show distance in word one day left or one hour use use this

# if needed, include actionview::helpers::datehelper distance_of_time_in_words_to_now(duedate) 

so

if datetime.now <= duedate     @distance_in_words = distance_of_time_in_words_to_now(duedate)     # else setup notification end 

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? -