Click here to Skip to main content
12,447,778 members (59,455 online)

JavaScript

 
QuestionHow does Yandex do its trick? Pin
Xarzu14-Nov-12 19:42
memberXarzu14-Nov-12 19:42 
AnswerRe: How does Yandex do its trick? Pin
Manfred R. Bihy14-Nov-12 20:44
mvpManfred R. Bihy14-Nov-12 20:44 
Questiondisplay record from two different time Pin
uti123fil8-Nov-12 17:15
memberuti123fil8-Nov-12 17:15 
AnswerRe: display record from two different time Pin
Richard MacCutchan8-Nov-12 23:47
mvpRichard MacCutchan8-Nov-12 23:47 
QuestionAdding a month to the current date Pin
SadiqMohammed6-Nov-12 23:48
memberSadiqMohammed6-Nov-12 23:48 
AnswerRe: Adding a month to the current date Pin
Richard Deeming7-Nov-12 2:00
memberRichard Deeming7-Nov-12 2:00 
GeneralRe: Adding a month to the current date Pin
SadiqMohammed7-Nov-12 18:31
memberSadiqMohammed7-Nov-12 18:31 
GeneralRe: Adding a month to the current date Pin
Richard Deeming8-Nov-12 2:11
memberRichard Deeming8-Nov-12 2:11 
I don't know how you've managed to get 1st April; with the code below, I get 2nd March:
var post_date = new Date(2012, 0, 31);
var expiration_date = new Date(post_date.setMonth(post_date.getMonth() + 1));
expiration_date = expiration_date.getMonth() + 1 + "/" + expiration_date.getDate() + "/" + expiration_date.getFullYear();
alert(expiration_date);

The reason it's 2nd March is that there is no 31st February. If you want the expiration_date to always be a date within the following month, you'll need to check that manually:
var post_date = new Date(2012, 0, 31);
 
var firstOfMonth = new Date(post_date);
firstOfMonth.setDate(1);
firstOfMonth.setMonth(post_date.getMonth() + 1);
 
var expiration_date = new Date(firstOfMonth);
expiration_date.setDate(post_date.getDate());
 
while (expiration_date.getMonth() != firstOfMonth.getMonth())
{
    expiration_date.setDate(expiration_date.getDate() - 1);
}
 
expiration_date = expiration_date.getMonth() + 1 + "/" + expiration_date.getDate() + "/" + expiration_date.getFullYear();
alert(expiration_date);

Alternatively, you could look at the Datejs library[^].



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Adding a month to the current date Pin
SadiqMohammed8-Nov-12 19:08
memberSadiqMohammed8-Nov-12 19:08 
AnswerRe: Adding a month to the current date Pin
deepak.m.shrma19-Nov-12 18:07
memberdeepak.m.shrma19-Nov-12 18:07 
GeneralRe: Adding a month to the current date Pin
Peter_in_278019-Nov-12 18:58
memberPeter_in_278019-Nov-12 18:58 
GeneralRe: Adding a month to the current date Pin
deepak.m.shrma19-Nov-12 19:52
memberdeepak.m.shrma19-Nov-12 19:52 
QuestionNeed to pass object value from javascript to php Pin
gern844-Nov-12 10:08
membergern844-Nov-12 10:08 
SuggestionRe: Need to pass object value from javascript to php Pin
n.podbielski4-Nov-12 12:56
membern.podbielski4-Nov-12 12:56 
GeneralRe: Need to pass object value from javascript to php Pin
gern844-Nov-12 13:29
membergern844-Nov-12 13:29 
GeneralRe: Need to pass object value from javascript to php Pin
n.podbielski4-Nov-12 20:48
membern.podbielski4-Nov-12 20:48 
GeneralRe: Need to pass object value from javascript to php Pin
zengnanhua22-Nov-12 18:27
memberzengnanhua22-Nov-12 18:27 
GeneralRe: Need to pass object value from javascript to php Pin
Killzone DeathMan22-Nov-12 23:39
memberKillzone DeathMan22-Nov-12 23:39 
QuestionWindow restore Pin
mkotaska1-Nov-12 6:00
membermkotaska1-Nov-12 6:00 
AnswerRe: Window restore Pin
ryanb312-Nov-12 11:03
memberryanb312-Nov-12 11:03 
Questionunzip the .gzip files Pin
KIDYA31-Oct-12 19:44
memberKIDYA31-Oct-12 19:44 
AnswerRe: unzip the .gzip files Pin
Jay Zhu2-Nov-12 17:20
memberJay Zhu2-Nov-12 17:20 
Questioni have created 3 widgets using jquery ui - header, footer, textarea. i am observing abnormal behavior because of the footer widget. Pin
Abhishek Prakash30-Oct-12 5:53
memberAbhishek Prakash30-Oct-12 5:53 
AnswerRe: i have created 3 widgets using jquery ui - header, footer, textarea. i am observing abnormal behavior because of the footer widget. Pin
n.podbielski30-Oct-12 21:48
membern.podbielski30-Oct-12 21:48 
GeneralRe: i have created 3 widgets using jquery ui - header, footer, textarea. i am observing abnormal behavior because of the footer widget. Pin
Abhishek Prakash30-Oct-12 23:40
memberAbhishek Prakash30-Oct-12 23:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 24 Aug 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid