[Show all top banners]

hurray
Replies to this thread:

More by hurray
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 Help with JavaScr|pt function
[VIEWED 1019 TIMES]
SAVE! for ease of future access.
Posted on 04-11-05 7:26 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

I have a web-page that has the info, 'This page was last updated on (suppose) 04/08/2005.'

What I would like, is to have this date change every 7 days beginning from 04/08/2005.

I have to update this page every seven day, and I would like the date to change dynamically without me having to change it whenever I make some changes to the page or even if I don't make any.

Any help would be grately appreciated. Thanks.

 
Posted on 04-11-05 8:16 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

hurray ji,
In what format are you passing your date ? Are you passing date in 04/11/2005 format for checking before updating ?
 
Posted on 04-11-05 8:31 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Any format. For now let's go with what you've mentioned.
 
Posted on 04-11-05 9:09 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

//try this one, your comments are welcome.
function FormatDate(strDate) // strDate should be in the format of 04/11/2005 or 4/11/2005 is also ok.
{
var strEffectiveDate = 20050408; // this is your effective date 04/08/2005
var temp;
temp = "";
var i = 0;

var month ="";
var day = "";
var year = "";
var l1=0;
var stop1 = false;
var stop2 = false;;
var x = 0;

var date= "";

while(i < str.length)
{
if(stop1 == false)
{
if(strDate.charAt(i) != "/")
{
month = month + strDate.charAt(i);
l1 = l1 + 1;
}
}

if(strDate.charAt(i) == "/")
{
stop1 = true;
}

if(i>l1)
{
if(stop2 == false)
{
if(strDate.charAt(i) != "/")
{
day = day + strDate.charAt(i);
x = i;
}
}
if(strDate.charAt(i) == "/")
{
stop2 = true;
}
}

i = i +1;
}

i = 0;
while(i < strDate.length)
{
year = year + strDate.charAt(x+2+i);
i=i+1
}

if(month.length == 1)
{
month = "0"+month;
}

if(day.length == 1)
{
day = "0"+day;
}

date = year+month+day;

return date; //Now the strDate (04/11/2005) is in the format of 20050411

}

//Now update your page, First check your effective date

var diffDays;
if(FormatDate(yourCurrentDate) > strEffectiveDate )
{
diffDays = FormatDate(yourCurrentDate) - strEffectiveDate;

if(parseInt(diffDays) % 7 == 0)
{

//Referesh your page - beause it is in every 7 days increment.

}
}
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 90 days
Recommended Popular Threads Controvertial Threads
TPS to F1 Status.
TPS To F-1 COS
TPS Sakiyo Tara Case is in Court.
Got my F1 reinstatement approved within 3 months(was out of F1 for almost 2 years)
Has anyone here successfully reinstated to F-1 status after a year-long gap following a drop from F-1?
Need Help of IT consultancies
Nepal TPS decision
Supreme Court allows Trump to end TPS for Venezuelans
Any input on remote jobs(IT related or Sales or Marketing)?
2020 : Why No Trump !
Nepal Likely to Get 60-Day TPS Notice
Nepal TPS has been Extended !!!
NEPAL TPS IS GONE
#MAGA#FAFO is delicious
नेपाल मा B. sc गरियो यहाँ फेरी ७० -८० क्रेडिट पढ्नु पर्ने भो
Genuine Question.... Why so many folks still in TPS after 10 years. Is the statistics wrong?
🛡️ Nepal TPS Holders: Don’t Panic About August 5 — DHS Screwed Up (Maybe on Purpose)
The New Color of Her Flag
Don’t Just Read—Join the Conversation
Travelling to Nepal with expiration less than 6 months
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters