473,395 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

need to add 15 days to date

I have tried everyway that I can think of to get this code to add 15 days with out the funky date happening and thus far no luck.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3. var currentTime = new Date();
  4. var month = currentTime.getMonth() + 1;
  5. var day = currentTime.getDate()
  6. var year = currentTime.getFullYear();
  7. document.write(month + "/" + day + "/" + year)
  8. //-->
  9. </script>
Feb 23 '11 #1
7 2277
Dormilich
8,658 Expert Mod 8TB
convert the date into a UNIX Timestamp (JS uses milliseconds) add 15 days in milliseconds, instantiate new Date object with this.
Feb 23 '11 #2
im new at this so i have no clue of how to do that. I am learning but as everything else takes time.
Feb 23 '11 #3
Dormilich
8,658 Expert Mod 8TB
then you definitely will need a solid reference page. I use MDC (Mozilla Developer Center). there are listed all methods and properties as well as usage examples.

(entry for Date)

by using that you should be able to code what I described in words.
Feb 23 '11 #4
Even more confused now. I see what you are taking about with the milliseconds but am completely confused on how to swith over what i have already to that.
Expand|Select|Wrap|Line Numbers
  1. new Date()
  2. Today = new Date();
  3. var ms;
  4. var currentTime = new Date();
  5. document.write(currentTime)
  6.  
Feb 23 '11 #5
acoder
16,027 Expert Mod 8TB
An even simpler way:

get the current day (getDate)
then set the day to that + 15 using setDate
Feb 23 '11 #6
I appriciate your help but this is getting me nowhere, as i have said I have done everything that I can think of and as much as I appriciate the point in the right direction when someone is already frustrated at the code that should be fairly simple for over a week and still cant get it to work properly it would be a great help and relief to see a little code that can help them get to where they need to be not just look here and look there. we come on this forum seeking help not to be told to look showhere else.
Feb 23 '11 #7
acoder
16,027 Expert Mod 8TB
From your original code, after line 6, add this:
Expand|Select|Wrap|Line Numbers
  1. currentTime.setDate(day+15);
You will then need to recalculate the day/month/year values to get the new date to display (the date object will now hold the new date).
Feb 24 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bob Stearns | last post by:
I have a column which is the relative day number to give a treatment on. For a particular patient, where I know the starting date, how do I show the actual date for each relative day? the best I...
2
by: Mary | last post by:
I am trying to develop a query which will determine the average costs using a rolling average of the past 12 months of data. In other words, if I entered the Ship Month of January and the Ship...
2
by: Gershon | last post by:
I have a simple table including First Name, Last Name, Start Date. I need to create a report listing First, Last and the number of days since Start Date. The First and Last names are easy. How do I...
1
by: jhdshydsguisfdbjk | last post by:
Get all the hots girls @ www.pearlymae.com
1
by: Eric | last post by:
In the subform user enters the dates. I need help when he is done with enteries of multiple rows program check the dates and the date which is max shows into another textbox name maxdate which is...
4
xstatic
by: xstatic | last post by:
After searching through the hundreds of links about "Javascript Date Formatting", all I am finding is how to format dates that gives a "current date" result. Here is what I need... I have a...
30
by: fniles | last post by:
On my machine in the office I change the computer setting to English (UK) so the date format is dd/mm/yyyy instead of mm/dd/yyyy for US. This problem happens in either Access or SQL Server. In the...
3
by: Tony B | last post by:
I'm trying to write a simple vb function that takes a current date and calculates for the first day of the month of that date what day of the week it is. I thought I could take a date object dt,...
3
by: scan87 | last post by:
Hello everyone, I have a problem with my PHP code. I want to add specific number of days to the current date, so that it will display the correct date after adding the number of days to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.