| Author |
Date convert help
|
Loges waran
Greenhorn
Joined: Feb 21, 2012
Posts: 9
|
|
Hi code ranch,
I need to get one logic.
For example, I have one Date 03-30-2012. My period is 10 days.
I need to subtract the number 10(Dynamic values may change) from 03-30-2012... The result should be 03-20-2012.
Can anybody help me for fixing this bug.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
What bug? You showed no code for a bug.
Did you look at the Date object? It has methods to get the date and its parts. https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date
Eric
|
 |
Loges waran
Greenhorn
Joined: Feb 21, 2012
Posts: 9
|
|
Hereer is the code:
var notifperiod = a.value;
var expirydate = b.value);
var notifdate = new Date(b.value);
var date1=notifdate.getDate();
notifdate.setDate(date1-notifperiod);
var notifdatefinal = (notifdate.getMonth()+1)+"-"+notifdate.getDate()+"-"+notifdate.getYear();
a.value=notifdatefinal;
In this code, when i enter April 5 as Expiry date and notification period as 10 days. it shows the result of 02-25-2012 It is not showing 03-25-2012.
But for if the difference between Expiry date & notif period occurs in the same month means its working fine.
Suggest me to solve this problem.
|
 |
 |
|
|
subject: Date convert help
|
|
|