![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Aug 2002
Posts: 269
|
java-script help - Modifying dates
I'm looking for a way to display not only the current date in "Month Day" format, but also a way to display one day back, two days back, three days back, and so on..
So in the date format, today's date would be "May 17" And yesterday's date would be "May 16", and so on... From browsing around some java-script sites on google I came across the code to display today's date in this format, but I can't figure out how to manipulate the code to subtract one day, two days, etc... I have an example page up here: http://www.grannytgp.com/month-day.html I'm not sure how much code the board will let me post with banned words -- don't want it all looking like "hahahahahaha", so I thought it would be best to throw up the example page ![]() One thing I was also thinking on this code is that it can't "break" when the month changes. So let's say it's now "June 01" The previous day will still need to be displayed at "May 31" Any help on this would be greatly apprecaited.
__________________
No sig = good sig ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Feb 2002
Posts: 1,424
|
something like this should work...havent tested it
var MINUTE = 60 * 1000 var HOUR = MINUTE * 60 var DAY = HOUR * 24 var WEEK = DAY * 7 var today = (new Date()).getTime() var yesterday = new Date(today - (DAY * 1)) var twodaysago = new Date(today - (DAY * 2)) |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Oct 2002
Posts: 148
|
<s.c.r.i.p.t.>
function DatePrint(days) { var today = new Date(); var theDate = new Date(today.valueOf()-days*86400000); var day = theDate.getDate(); getmonth = theDate.getMonth(); var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); month = monthArray[getmonth]; var ds = ''; if (day < 10) ds = '0'; document.write(month + " " + ds + day); } </s.c.r.i.p.t.> <s.c.r.i.p.t.>DatePrint(1)</s.c.r.i.p.t.> ----------------- (1) - means yesterday, (7) - a week ago and so on. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
Confirmed User
Join Date: Aug 2002
Posts: 269
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |