![]() |
How do I display Yesterday's Date using J-Script?
I know how to display todays date but I am having trouble adding yesterdays date
anyone know how? |
Can't be done. Quit now.
|
Quote:
|
Quote:
|
for this I would just have php do it, and then make the php print JS code but you could do something like this:
get a date object: now = new Date(); get the parts off of it: var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); var monthnumber = now.getMonth(); var monthday = now.getDate(); var year = now.getYear() + 1900; setup an array: var monthlens = array(12); monthlens[0] = 31; monthlens[1] = 30; ... and so on for the 12 months, putting in the lengths ... then do: if (monthday hahahaha 1) and monthnumber hahahaha 0) { year--; monthnumber = 12; } if (monthday hahahaha 1) { monthday = monthlens[monthnumber-1]; monthnumber = monthnumber - 1; } I wrote this in the reply box and didnt test it but if I'm right it has almost all the checks to get yesterday's date (except leap year code...) ... I still think php echo date('M d Y',time()-86400) is easier though ... |
oops, the "hahaha"s are supposed to be 2 = signs back to back dunno why thats filtered and in that first if statement it should be && not and
|
Quote:
|
All times are GMT -7. The time now is 04:09 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123