Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > JavaScript Dates

JavaScript Dates
Thread Tools
pumpkinapo
Junior Member
Join Date: Aug 2000
Location: Califon, NJ
Status: Offline
Reply With Quote
Sep 18, 2001, 09:47 AM
 
Does anyone know how to increment a date with JavaScript. I'm trying to take one date, say 9/18/2001, and add seven days to it, to get 9/25/2001. Thanks in advance.
Peter Leing
17" 1.67GHz PowerBook
450MHz G4 Cube
     
zorn
Dedicated MacNNer
Join Date: Feb 2001
Location: Meida, PA USA
Status: Offline
Reply With Quote
Sep 18, 2001, 02:17 PM
 
The following article will prob help:
http://www.webreference.com/js/tips/010220.html

as well as a personal one I wrote:
http://www.mikezornek.com/features/j...wn/index.shtml

Both take you step by step thru writing two different day-type programs. But most likly it will be as easy as

myDateVar += 8;

If I'm wrong or further questions please ask

~ Mike
~ Mike
--
Personal Site: MikeZornek.com
Other Interests: WebDevWiki.com
     
zekemon6
Junior Member
Join Date: Oct 2001
Location: Oxford, OH
Status: Offline
Reply With Quote
Nov 2, 2001, 09:43 PM
 
Here's a script I wrote to print out the date, if anyone would like to use it:

<script language="JavaScript" type="text/javascript">
<!--
<!-- hide from Ye Olde browsers
// Zeke Runyon | [email protected] | zekeworld.home.dhs.org
// zekemon date stamp function v1.0
function dateStamp() {
var months = new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December");
var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thu rsday","Friday","Saturday");
var gotdate = new Date();
var day = days[gotdate.getDay()];
var month = months[gotdate.getMonth()];
var date = gotdate.getDate();
var year = gotdate.getYear();
if (year < 2000) { year = year + 1900; }
document.write(day + ", " + month + " " + date + ", " + year);
}
// come out from hiding -->
</script>

To print out the date, just say

<script>dateStamp();</script>
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 01:13 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,