Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return only time irrelevant date javascript

Tags:

javascript

My question is more about logic not code.I created something called prepared messages with time i supply to each new message, i compare the time with current time and give each row a background. Is it possible for me to fetch the time with javascript only the current time NO DATE. Regards

like image 914
Sarah Avatar asked Oct 15 '22 10:10

Sarah


1 Answers

To compare only the time, without year, month and day taken into account, try the following:

var now = new Date().setFullYear(1, 0, 1)
,   andThen = new Date(dateMessageSent).setFullYear(1, 0, 1)

if (now > andThen) doYourStuff()
like image 152
Technomad Avatar answered Nov 15 '22 09:11

Technomad