I'm working on some interactive class notes/syllabi for a class, and I wanted to pop in a little joke at the end depending on what time the student finishes everything. Is there any way to pull the time on the computer itself and then put that value in an if statement?
Thanks!
Comments
<br /><<set $due = new Date(2014, 5, 18, 0, 0, 0)>><br /><<if Date.now() gt $due>><br />You are supposed to be done already!<br /><<endif>> <br />
Note the weird one-off in the Date constructor (year, month, day, hour, minute, second): months start at zero, so June is 5, not 6.
// Peter
Unless you wanted to emit a different message, then the cases "after midnight" and "after midnight the day it's due" are both handled by "after midnight".
One way of doing that would be like so: (emits its message if the hour is between 126 AM local time) If you wanted to compare against a specific date and time, then something like what peterorme posted would work. Though, I would probably do it as: Of course, you can also combine them: (all in local time)