aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Date convert help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Date convert help" Watch "Date convert help" New topic
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: 15376
    
    6
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date convert help
 
Similar Threads
Finding Timestamp pattern from a String
Getting first date of next month
Code review required for converting dateformat
Materials for OCPJP 7 Upgrade - Beta
curl "not recognized as internal or external command"