PDA

View Full Version : How do I add today's date to website?



pigletxx
02-11-2006, 05:48 PM
Hi,
I'm not sure where to post this..eeekkk!
But i'd like to add today's date & possibly the time to my website... does blue voda offer a programme that does this?

Many thanks

the ever learning pigletxx

racefan20
02-11-2006, 06:10 PM
Yes. In BlueVoda, go to Insert> Ready To Use Javascripts.

pigletxx
02-11-2006, 06:49 PM
Hi thaks for your reply,
Found the javascript... but now how do i input the date that automatically updates itself everyday? do i need a specific date program or something?

a sighing pigletxx

racefan20
02-11-2006, 06:59 PM
The javascript in BV does that for you.

pigletxx
02-11-2006, 07:15 PM
It's me again... found insert>javascript - but not - Ready to Use Javascripts. so what are they?

Might be easier & less frustrating for you if maybe you take me through it from the beginning. so far I have my index.html page infront of me. I want it to display the date maybe the time, something that will update itself.

A struggling to get it pigletxx X:o)

navaldesign
02-11-2006, 07:17 PM
The javascript in BV does that for you.

Hi Racefan, you have mail

Let's give our friens a hand:

Open a html box in your page. Double click it to edit it. In the window that opens put this code:

<form name=myForm>
<input type=button value="Loading..." name=clock></form>
<SCRIPT LANGUAGE="JavaScript"><!--
function runClock(){
theTime = window.setTimeout("runClock()", 1000);
d = new Date();
day = d.getDay();
mon = d.getMonth();
date = d.getDate();
year = d.getYear();
hr = d.getHours();
min = d.getMinutes();
sec = d.getSeconds();
if(year<1000){year=(""+(year+11900)).substring(1,5);}
else{year=(""+(year+10000)).substring(1,5);}
if(hr==0){ap=" AM";hr=12}
else if(hr <= 11){ap=" AM"}
else if(hr == 12){ap=" PM";hr=12}
else if(hr >= 13){ap=" PM";hr-=12}
if(min <= 9){min="0"+min}
if(sec <= 9){sec="0"+sec}
zday=new Array();
zday=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
zmon=new Array();
zmon=["January","February","March","April","May","June","July","August","September","October","November","December"];

document.myForm.clock.value=""+zday[day]+", "+zmon[mon]+" "+date+", "+year+" "+hr+":"+min+":"+sec+ap+"";}
runClock();
//--></script>



Put the html box wherever you like in your page.

pigletxx
02-11-2006, 07:29 PM
It worked!! Thanks everso.... easy when you know how eh? lol

Can I just pick your brains on something else... is it possible for the date just to be in dark blue (navy) font without the 'box/button"?

a very grateful pigletxx

navaldesign
02-11-2006, 07:45 PM
It worked!! Thanks everso.... easy when you know how eh? lol

Can I just pick your brains on something else... is it possible for the date just to be in dark blue (navy) font without the 'box/button"?

a very grateful pigletxx

Sorry, this is a ready made script. There are others that give separataly the date and the time, then you can combine them. Make a search

pigletxx
02-11-2006, 07:48 PM
Thank for all your time & help.... it's been brill!

bless you X:o)

A very thankful pigletxx

kenkew
02-17-2006, 11:57 AM
Nice one NavalD...I just borrowed it too. Works a treat. Mind having a go at solving my other nittypicky thingy. Q. is here someplace, Published site problems...It's not the 'puzzle query, I solved that. It's FTP problem I think.

navaldesign
02-17-2006, 12:11 PM
Nice one NavalD...I just borrowed it too. Works a treat. Mind having a go at solving my other nittypicky thingy. Q. is here someplace, Published site problems...It's not the 'puzzle query, I solved that. It's FTP problem I think.

So what's your problem, if any?

christian_woman
02-24-2006, 09:19 PM
This script is wonderful. I just added it to my website. Thanks for making my day unexpectedly great!

doug145
10-02-2006, 06:48 PM
Navaledesign, or Anyone:

How do I add 28 calendar days to today's date and display that value? Do you have a script for doing that?

Doug

navaldesign
10-03-2006, 11:06 AM
No, i don't. I beleive one can be easily made if one has a reference point (sorry, i don't know what is the date according to the 28 day calendar). Give me a reference point, and the month names and i'll see if can prepare something for you.

doug145
10-03-2006, 09:14 PM
All I want to do is add 28 days to whatever today's date is and display it. Todays date will always change, so that value will always change also.

doug145
10-08-2006, 09:16 PM
Can anyone still help me on my last question? I need a javascript that will add 28 days to today's date and display it.

Doug

navaldesign
10-09-2006, 06:33 AM
Please note that the 28 days calendar doen't simply add 28 days to the present date. The 28 days calendar is based on a 13 month (instead of 12) basis, which makes 28X13=364 plus one "Rest "day. And, it is counted from a reference date. So if you want to display the 28 say calendar correctly, you need to have that reference date.

doug145
10-09-2006, 05:51 PM
I do not care about a 28 days calendar. (It was only by coincidence that I said 28, but that may change for me anyway). I may as well be trying to add 11 days, or 16 days, or 55 days for that matter. Just give me an example where ANY NUMBER of days are added to today's date and that new date is displayed.

Doug

navaldesign
10-09-2006, 05:56 PM
Ok, i'll figure out something for you. Let you know tomorrow. Must it be Javascript or can it be server side (php) ? Please note that if it is php, you need to publish your pages as php

doug145
10-10-2006, 03:18 PM
Just some javascript that I can set right on my page is all I need.

Doug

doug145
10-11-2006, 04:33 PM
Navaldesign,

Just wondered if you might have a script for me yet. Your help is appreciated.

Doug

navaldesign
10-11-2006, 05:03 PM
Working on it. It is harder to do if you need a variable number of days, as it has to take care also of 1. Day change (F.e. if you want a 8 day difference, Monday should become Tuesday, if you need a 10 days difference, Monday should become Thirsday and so on) 2. Month change (you need to check if the month changes f.e. adding 28 days to September 4 makes it October 2, whilst adding 28 days to October 4 makes it November 3: depends on the month days, which are variable 28,29,30,31) 3. Year change (adding 15 days to 20 December 2006 makes it January 4 2007)

I think i'll make it, just give me some time.

doug145
10-12-2006, 09:22 PM
Here is an example of adding 5 days, but I cannot get it to work in Blue Voda:

// Get today's date
Calendar now = Calendar.getInstance();
Calendar working;
SimpleDateFormat formatter = new SimpleDateFormat("E yyyy.MM.dd 'at' hh:mm:ss a zzz");

working = (Calendar) now.clone();
working.add(Calendar.DAY_OF_YEAR, + 5);
prt(" In five days it will be: " + formatter.format(working.getTime()));

prt();

}

navaldesign
10-13-2006, 06:39 AM
Here is something simple. It can work for positive differences up to 31 days, but it will not work correctly if the new date goes over 28 February and, in the same time, February has 29 days. Since this is going to happen in 2008, you have more than one year to find another solution. Copy the code and simply paste it in a html box in your page. Then place the html box anywhere you want it in your page. To edit the days period, edit the number in RED

<form name=myForm2>
<input type=button value="Loading..." name=clock></form>
<SCRIPT LANGUAGE="JavaScript"><!--
function runClock(){
theTime = window.setTimeout("runClock()", 1000);
d = new Date();
mon = d.getMonth();
date = d.getDate();
year = d.getYear();
hr = d.getHours();
min = d.getMinutes();
sec = d.getSeconds();
diff = 25
date2 = date;
date+=diff;
monthdays = new Array();
monthdays = [31,28,31,30,31,30,31,31,30,31,30,31];
if(date>monthdays[mon]){date-=monthdays[mon] ; mon+=1}
if (mon>13) {mon-=12 ; year+=1}


if(year<1000){year=(""+(year+11900)).substring(1,5 );}
else{year=(""+(year+10000)).substring(1,5);}
if(hr==0){ap=" AM";hr=12}
else if(hr <= 11){ap=" AM"}
else if(hr == 12){ap=" PM";hr=12}
else if(hr >= 13){ap=" PM";hr-=12}
if(min <= 9){min="0"+min}
if(sec <= 9){sec="0"+sec}
zmon=new Array();
zmon=["January","February","March","April","May","June", "July","August","September","October","November"," December"];
document.myForm2.clock.value=""+zmon[mon]+" "+date+", "+year+" "+hr+":"+min+":"+sec+ap+"";}
runClock();
//--></script>

doug145
10-13-2006, 04:16 PM
NavalDesign: THANK YOU so much! Just what I was looking for.

Doug

doug145
12-20-2006, 06:21 PM
Hi Navaldesign,

The script you gave me has been working fine until now. But it is not working now because it has to cross into January of next year with its date difference. The proper date is not displaying now. Could you please look at the script again and correct it so it will display the right date in January? It looks like you put code in to take care of yearly crossovers, but it is not working right.

Doug

navaldesign
12-20-2006, 07:56 PM
Can you please provide me with a link to the page with the script ?

doug145
12-20-2006, 08:02 PM
I temporarily removed it from the page since is was not working.

If you would, just create a blank web page and do a create HTML box and preview it from there?

Here is the code I have:

<form name=myForm2>
<input type=button value="Loading..." name=clock></form>
<SCRIPT LANGUAGE="JavaScript"><!--
function runClock(){
theTime = window.setTimeout("runClock()", 1000);
d = new Date();
day = d.getDay();
mon = d.getMonth();
date = d.getDate();
year = d.getYear();
hr = d.getHours();
min = d.getMinutes();
sec = d.getSeconds();
diff = 14
date2 = date;
date+=diff;
monthdays = new Array();
monthdays = [31,28,31,30,31,30,31,31,30,31,30,31];
if(date>monthdays[mon]){date-=monthdays[mon] ; mon+=1}
if (mon>13) {mon-=12 ; year+=1}
if(year<1000){year=(""+(year+11900)).substring(1,5 );}
else{year=(""+(year+10000)).substring(1,5);}
if(hr==0){ap=" AM";hr=12}
else if(hr <= 11){ap=" AM"}
else if(hr == 12){ap=" PM";hr=12}
else if(hr >= 13){ap=" PM";hr-=12}
if(min <= 9){min="0"+min}
if(sec <= 9){sec="0"+sec}
zmon=new Array();
zmon=["January","February","March","April","May","June", "July","August","September","October","November"," December"];
zday=new Array();
zday=["Sunday","Monday","Tuesday","Wednesday","Thursday" ,"Friday","Saturday"];
document.myForm2.clock.value="Fourteen days from now will be "+zday[day]+", "+zmon[mon]+" "+date+", "+year+"";}
runClock();
//--></script>

Thanks!

Doug

doug145
12-27-2006, 09:24 PM
Guess no one is around to answer me on this. It should resolve itself come Jan 1. Anyone is invited to reply though, if you have nothing else to do for the next few days.

navaldesign
12-28-2006, 08:27 AM
Sorry, my mistake. The Months numbering for the script starts from 0, so the correct script should be as follows:

<form name=myForm2>
<input type=button value="Loading..." name=clock></form>
<SCRIPT LANGUAGE="JavaScript"><!--
function runClock(){
theTime = window.setTimeout("runClock()", 1000);
d = new Date();
day = d.getDay();
mon = d.getMonth();
date = d.getDate();
year = d.getYear();
hr = d.getHours();
min = d.getMinutes();
sec = d.getSeconds();
diff = 14
date2 = date;
date+=diff;
monthdays = new Array();
monthdays = [31,28,31,30,31,30,31,31,30,31,30,31];
mon1 = mon
if(date>monthdays[mon1]){mon+=1}
if(date>monthdays[mon1]){date-=monthdays[mon1]}
if(mon>11){year+=1}
if(mon>11){mon-=12}
if(year<1000){year=(""+(year+11900)).substring(1,5 );}
else{year=(""+(year+10000)).substring(1,5);}
if(hr==0){ap=" AM";hr=12}
else if(hr <= 11){ap=" AM"}
else if(hr == 12){ap=" PM";hr=12}
else if(hr >= 13){ap=" PM";hr-=12}
if(min <= 9){min="0"+min}
if(sec <= 9){sec="0"+sec}
zmon=new Array();
zmon=["January","February","March","April","May","June", "July","August","September","October","November"," December"];
zday=new Array();
zday=["Sunday","Monday","Tuesday","Wednesday","Thursday" ,"Friday","Saturday"];
document.myForm2.clock.value=" Fourteen days from now will be "+zday[day]+", "+zmon[mon]+" "+date+", "+year+"";}
runClock();
//--></script>

doug145
12-28-2006, 01:45 PM
Thanks, Navaldesign! How did you learn how to program Javascript, btw?

Doug

navaldesign
12-28-2006, 03:59 PM
I don't know how to program in javascript. I'm just using my php knowledge which has some similarities with Javascript.

Danny Canada
04-04-2007, 06:45 PM
Hi Naval

Is there a way to have the date and time as just text and in a smaller font (without the button)?

Thanks!



Hi Racefan, you have mail

Let's give our friens a hand:

Open a html box in your page. Double click it to edit it. In the window that opens put this code:

<form name=myForm>
<input type=button value="Loading..." name=clock></form>
<SCRIPT LANGUAGE="JavaScript"><!--
function runClock(){
theTime = window.setTimeout("runClock()", 1000);
d = new Date();
day = d.getDay();
mon = d.getMonth();
date = d.getDate();
year = d.getYear();
hr = d.getHours();
min = d.getMinutes();
sec = d.getSeconds();
if(year<1000){year=(""+(year+11900)).substring(1,5);}
else{year=(""+(year+10000)).substring(1,5);}
if(hr==0){ap=" AM";hr=12}
else if(hr <= 11){ap=" AM"}
else if(hr == 12){ap=" PM";hr=12}
else if(hr >= 13){ap=" PM";hr-=12}
if(min <= 9){min="0"+min}
if(sec <= 9){sec="0"+sec}
zday=new Array();
zday=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
zmon=new Array();
zmon=["January","February","March","April","May","June","July","August","September","October","November","December"];

document.myForm.clock.value=""+zday[day]+", "+zmon[mon]+" "+date+", "+year+" "+hr+":"+min+":"+sec+ap+"";}
runClock();
//--></script>



Put the html box wherever you like in your page.

ofirbeigel
10-03-2008, 11:05 AM
Hey.
How can I add just a date without the current time ?

davidundalicia
10-03-2008, 11:32 AM
Bluevoda tips and tricks section HERE (http://www.vodahost.com/vodatalk/bluevoda-tips-tricks-shortcuts/41410-free-day-date-script-when-you-review-page.html)

and this thread is a great blast from the past.....................

preemahe
11-12-2008, 04:29 PM
Thank you....

davidundalicia
11-12-2008, 04:37 PM
Your welcome..............