...

View Full Version : changes month and date



kijons
11-18-2010, 10:59 PM
Hello, and thanks for a great forum

I have downloaded a script called Display time of last visit.

Since I live in Norway, so the date is on the wrong line. It's November 18, but I want the date to be before the month if ya know what I mean. Is there anyone out there who can be so kind and help me change the script so that it is correct? I've tried, but .....

this is what it says now:

Thursday, November 18, 2010 09:59:28 AM I want it to be (is it is possibe to remove AM ?)
Thursday, 18, November 2010 09:59:28 AM



Sincerely, from Norway

Jon
isprinsessa.com

Old Pedant
11-18-2010, 11:13 PM
Try using toLocaleDateString() instead of just toString().

If that's still not in the format you prefer, then you will need to create the string "in pieces" with coding.

If you don't understand what I wrote, show your existing code.

kijons
11-19-2010, 06:29 PM
Hello, and thanks for a quick answer

I tried and replace ToString () with ToLocaleDateString (), but it did nothing .... I got the same order :-(... can you be so kind and help me?

( I have no idea on script :-)




Sincerely from Norway

Jon
isprinsessa.com (http://isprinsessa.com)



ps: how can I upload the script file? ( can I give the file on some mail?)

Philip M
11-19-2010, 07:02 PM
We cannot help you unless you show your relevant code, that is the code which produces the date output.

Or are you refering to the script at
http://www.javascriptkit.com/script/script2/lastvisit.shtml

If so just change the line

var dispDate = dy + ", " + mn + " " + dd + ", " + yy + " " + hh + ":" + mins + ":" + secs + " " + ampm

to:-

var dispDate = dy + ", " + dd + " " + mn + ", " + yy + " " + hh + ":" + mins + ":" + secs;

I would have thought that was sufficiently obvious for you to work out how to to make that alteration yourself.

Note that if you remove AM/PM then 2000 hours will show as 0800. So you should delete these lines:-

var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}

Or of course replace AM/PM with whatever the Norwegian abbreviations are.

kijons
11-19-2010, 07:12 PM
Hello

Yeessss:thumbsup:

It is this code yes

Jon


ps: The clock shows 8:15 (In Norway, are this morning, but the time no is 20:15 that evening)

kijons
11-19-2010, 07:23 PM
Hello:):):):):):)


Yeessss:thumbsup::thumbsup: I get the ringt date now, but the time showing wrong in Norway....se the message before

I removed the line: if (hh < 10) {hh = "0" + hh}; but the time is stil the same

sorry people .... but I'm compleaty blanks on this ,,,,, you are very patient


Jon
Norway

Philip M
11-19-2010, 07:30 PM
See Post#4.


I removed the line: if (hh < 10) {hh = "0" + hh}; but the time is stil the same

That line simply adds a leading zero to hours under 10.

kijons
11-19-2010, 07:36 PM
hello

it is possible to put in the text clock before the hour?

Jon

ps: We have not something called AM or PM, we have last 24 hours clock system

Old Pedant
11-19-2010, 07:57 PM
If you are still getting the wrong time, *SHOW YOUR CODE* that you are using *NOW*.

Yes, of course you can add "clock". Or anything you want.


var dispDate = "clock " + dy + ", " + dd + " " + mn + ", " + yy + " " + hh + ":" + mins + ":" + secs;

kijons
11-19-2010, 08:03 PM
<br />
<div style="text-align: center;"><script type = "text/javascript">

/***********************************************
* Display time of last visit script- by JavaScriptKit.com
* This notice MUST stay intact for use
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
***********************************************/

var days = 730; // days until cookie expires = 2 years.
var lastvisit=new Object();
var firstvisitmsg="Dette er ditt første besøk på denne siden. Velkommen!";
lastvisit.subsequentvisitmsg="Velkommen tilbake besøkende!<br><br>Ditt siste besøk på vår side var <b>[displaydate]</b>";

lastvisit.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1];
return'';
}

lastvisit.setCookie=function(name, value, days){
var expireDate = new Date();

var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days));
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

lastvisit.showmessage = function() {
var wh = new Date();
if (lastvisit.getCookie("visitc") == "") {
lastvisit.setCookie("visitc", wh, days);
document.write(firstvisitmsg);
}

else {
var lv = lastvisit.getCookie("visitc");
var lvp = Date.parse(lv);
var now = new Date();
now.setTime(lvp);
var day = new Array("Sømdag", "Mandag", "Tirsdag", "onsdag", "Torsdag", "Fredag", "Lørdag");
var month = new Array ("Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember");
var dd = now.getDate();
var dy = now.getDay();
dy = day[dy];
var mn = now.getMonth();
mn = month[mn];
yy = now.getFullYear();
var hh = now.getHours();
var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}
var dispDate = dy + ", " + dd + " " + mn + ", " + yy + " " + hh + ":" + mins + ":" + secs;
document.write(lastvisit.subsequentvisitmsg.replace("[displaydate]", dispDate))
}

lastvisit.setCookie("visitc", wh, days);

}

lastvisit.showmessage();

</script></div>

Old Pedant
11-19-2010, 08:16 PM
You did *NOT* delete the lines Philip told you to!!! (in post #4)

You need to REMOVE (delete, take out, throw away) these lines:


var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}

And then, optionally, you can add the clock as I showed.

kijons
11-19-2010, 08:24 PM
Hello :)

I deleted just the line if (secs < 10) {secs = "0" + secs}...but I will deleted all


and the text clock:

var dispDate = "clock " + dy + ", " + dd + " " + mn + ", " + yy + " " + hh + ":" + mins + ":" + secs;


I try to move clock before the hh, but someting is wrong..:rolleyes:

Jon

kijons
11-19-2010, 08:26 PM
yeeeeehhhhh:thumbsup:


thanks....now I have just the text clock again :thumbsup:

Jon
Norway

kijons
11-19-2010, 08:36 PM
Hello

I made it:p:o to move the clock

I wil say many thanks to all help :D

From Norway

Jon
isprinsessa.com (http://isprinsessa.com)

kijons
11-19-2010, 09:27 PM
Hello again :)


This script .... it's just that I get to see it on my machine ????... We are sitting on multiple PCs in the house, but they can not see the new schript ... What is it .. .. can it be that it records Ip adressse ?..... everyone should just watch it


From Norway

Jon
isprinsessa.com (http://isprinsessa.com,)

Old Pedant
11-19-2010, 09:55 PM
If you changed the file on your machine but the other people are still looking at the old version of the file, then of course they won't see it.

But it *COULD* be that their machines have cached the old version. Bring up the page and then hit CTRL-F5. That is, hold down the CTRL key while hitting the F5 key. That will *force* the browser to refresh the page.

If that doesn't work, the problem is that you changed the file ONLY where your machine can see it. I have no idea what your network is like at your house and where the server is.

kijons
11-19-2010, 10:15 PM
Hello, and thanks for the answer, they could not see the old script either ...


....Can you see the script on my site? (on the front)



regards fron Norway

Jon
isprinsessa.com (http://isprinsessa.com)

Old Pedant
11-19-2010, 10:46 PM
Nope. Or, rather, the script *IS* there, but it is doing nothing at all.

kijons
11-19-2010, 11:18 PM
Hello

I have write some text in ÆØÅ....I think this script not taken ÆØÅ ??:eek:

I will try some else text....

Jon

Old Pedant
11-19-2010, 11:23 PM
No, I think the script is just badly written.

Way overcomplicated. Too much code.

kijons
11-19-2010, 11:27 PM
hmmmm...can you try some times to refresh the site?....and see?

The others laptop in house can see the script now, but can you?



From Norway

Jon
isprinsessa.com (http://isprinsessa.com)

Old Pedant
11-19-2010, 11:56 PM
I see it saying I am "new here".

So I guess it is now working.

kijons
11-20-2010, 12:01 AM
thanks:D


I have not changes the time to Norwegian, but...:eek:I will try...will you giv me feedback?:p


regards

Jon

ps: I try to set Norwegian time, but they dont work on othets laptop

I set the orginal script, they the work.

kijons
11-20-2010, 12:35 AM
Hello again


Can somebody fix it for me?....how I can get it to work in Norwegia time ? (we have just 24 timer not AM or PM)


I chould changes somthing here?...but what:o

var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}


Jon

Old Pedant
11-20-2010, 12:55 AM
PHILIP told you in post #4:
http://www.codingforums.com/showpost.php?p=1017794&postcount=4

I told you in post #11:
http://www.codingforums.com/showpost.php?p=1017794&postcount=4

I will try ONE MORE TIME.

REMOVE
DELETE
DESTROY
GET RID OF
the lines in RED here:


var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}

DO NOT CHANGE ANY OTHER LINES.

Just REMOVE the ones in RED.

kijons
11-20-2010, 12:58 AM
Yes I understand that...but when I do that, the chript wil not work on others laptop in house.

I know I get the Norwegian time when I remove the line:cool:

aahhaaa....I removed five lines. Now I removed just four line


Jon


ps: Can you see the script on my page now?

Old Pedant
11-20-2010, 01:24 AM
Ditt siste besøk var fredag, 19 november, 2010 klokken 15:55

kijons
11-20-2010, 01:33 AM
yessss:thumbsup::p

I deleted one line too much, so it was therefore the chript not working :rolleyes:


thanks Old Pedant.....thanks for all your help ...

you are very kind and very patient ....

have a nice day to you and your

from Norway

Jon



(eeeehhhhh......I turn of one of the laptop, and turnes on again and gues what??...the chript does not show)....I giv up soon :-(

Philip M
11-20-2010, 08:11 AM
(eeeehhhhh......I turn of one of the laptop, and turnes on again and gues what??...the chript does not show)....I giv up soon :-(

The fault, dear Brutus, lies not in the stars but ......... :D

I see

Ditt siste besøk var lørdag, 20 november, 2010 klokken 08:09:21 AM

We have explained several times how to remove the AM/PM :(

I have to say that your site throws an error at Line 1422 - object expected, and seems to have a fault which consumes excessive resources - 44% CPU usage on my machine.

kijons
11-20-2010, 12:16 PM
Hello Philip;)

I have tryed to removed the line you told me. When I do that, the script can not be updated when somebody comes back to my site. Someone should not see the chript on my site. I think the error in line 1422 you told me, may be the new script. This site is built in php, it may be that this new script makes this error in line 1422?

Regards from Norway

Jon

Isprinsesa.com (http://isprinsessa.com)

Philip M
11-20-2010, 12:30 PM
It works just fine for me. :) You have been given ample detailed instructions showing you how to make this script work. If you cannot do that, "The fault, dear Brutus, lies not in the stars but ......... ":D

Be aware that the slightest error, even missing out a , or a ( will almost certainly cause the script to fail. Naturally the same applies if you delete the wrong lines, or additional lines. Have you used your error console?

Presumably you would not attempt to service or repair a machine or appliance without any experience or understanding of how it worked. :p

It is obvious that you yourself did not create your website. Why do you not ask for help from the person who developed your site?

kijons
11-20-2010, 01:48 PM
Hello Philip;)

The portal, which I have called GuppY (freeguppy.org). The only thing I have done is to convert the English files into Norwegian. (Think I have almost 40 plugins) .. Plugins are additional boxes :-)... I've gotten MUCH help with this page ... We have had a website since 2004, but a LOT has been done ... I find new plugins olmost every day ....and I mus try :rolleyes: but I'm a little too fast on the fingers on the keyboard, when I add the discount via my ftp. (Can say I have deleted and uploaded since many times, so this I have good experience with :-) Have heard that the page may be a bit heavy to load, since there are so many plugins. I have 6 schript with java in my page.


From Norway

Jon
isprinsessa.com

kijons
11-20-2010, 02:02 PM
As said. I have tried many times to deleted the lines that I've been told, but the script will not update when I press refresh the page. Now I have the original hours and when I see that the script works fine. but it is a little error in relation to the time in Norwegian to ..... but, but ...

Jon

ps: I try to deleted the time lines, but now the script will dont work ?

var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}

Philip M
11-20-2010, 02:12 PM
This is getting a mite tedious. :(

Did you change the line:-

var dispDate = dy + ", " + mn + " " + dd + ", " + yy + " " + hh + ":" + mins + ":" + secs + " " + ampm

to:-

var dispDate = dy + ", " + dd + " " + mn + ", " + yy + " " + hh + ":" + mins + ":" + secs;


If you do not follow the instructions you are bound to have problems.

Be aware that Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

kijons
11-20-2010, 02:29 PM
Yes, I have changed this line too

I will now show the script that I have made changes, so you can see for yourself.

add first out the original, then it is modified (which I use) ...can you now try to "refresh" you page and see if the time changes?
Jon



orginal



<script type = "text/javascript">

/***********************************************
* Display time of last visit script- by JavaScriptKit.com
* This notice MUST stay intact for use
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
***********************************************/

var days = 730; // days until cookie expires = 2 years.
var lastvisit=new Object();
var firstvisitmsg="This is your first visit to this page. Welcome!";
lastvisit.subsequentvisitmsg="Welcome back visitor! Your last visit was on <b>[displaydate]</b>";

lastvisit.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1];
return'';
}

lastvisit.setCookie=function(name, value, days){
var expireDate = new Date();

var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days));
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

lastvisit.showmessage = function() {
var wh = new Date();
if (lastvisit.getCookie("visitc") == "") {
lastvisit.setCookie("visitc", wh, days);
document.write(firstvisitmsg);
}

else {
var lv = lastvisit.getCookie("visitc");
var lvp = Date.parse(lv);
var now = new Date();
now.setTime(lvp);
var day = new Array("Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat");
var month = new Array ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var dd = now.getDate();
var dy = now.getDay();
dy = day[dy];
var mn = now.getMonth();
mn = month[mn];
yy = now.getFullYear();
var hh = now.getHours();
var ampm = "AM";
if (hh >= 12) {ampm = "PM"}
if (hh >12){hh = hh - 12};
if (hh == 0) {hh = 12}
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}
var dispDate = dy + ", " + mn + " " + dd + ", " + yy + " " + hh + ":" + mins + ":" + secs + " " + ampm
document.write(lastvisit.subsequentvisitmsg.replace("\[displaydate\]", dispDate))
}

lastvisit.setCookie("visitc", wh, days);

}

lastvisit.showmessage();

</script>



this is what I use now



<div style="text-align: center;"><script type = "text/javascript">

/***********************************************
* Display time of last visit script- by JavaScriptKit.com
* This notice MUST stay intact for use
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and more
***********************************************/

var days = 730; // days until cookie expires = 2 years.
var lastvisit=new Object();
var firstvisitmsg="Dette er ditt første besøk på vår side. Velkommen!";
lastvisit.subsequentvisitmsg="Velkommen tilbake til siden vår!...Vi håper du trives her!<br><br> Ditt siste besøk var <b>[displaydate]</b>";

lastvisit.getCookie=function(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1];
return'';
}

lastvisit.setCookie=function(name, value, days){
var expireDate = new Date();

var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days));
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

lastvisit.showmessage = function() {
var wh = new Date();
if (lastvisit.getCookie("visitc") == "") {
lastvisit.setCookie("visitc", wh, days);
document.write(firstvisitmsg);
}

else {
var lv = lastvisit.getCookie("visitc");
var lvp = Date.parse(lv);
var now = new Date();
now.setTime(lvp);
var day = new Array("sømdag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag");
var month = new Array ("januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "Oktober", "november", "desember");
var dd = now.getDate();
var dy = now.getDay();
dy = day[dy];
var mn = now.getMonth();
mn = month[mn];
yy = now.getFullYear();
var hh = now.getHours();
if (hh < 10) {hh = "0" + hh};
var mins = now.getMinutes();
if (mins < 10) {mins = "0"+ mins}
var secs = now.getSeconds();
if (secs < 10) {secs = "0" + secs}
var dispDate = dy + ", " + dd + " " + mn + ", " + yy + " " + hh + ":" + mins + ":" + secs;
document.write(lastvisit.subsequentvisitmsg.replace("[displaydate]", dispDate))
}

lastvisit.setCookie("visitc", wh, days);

}

lastvisit.showmessage();

</script></div>

Philip M
11-20-2010, 03:54 PM
As far as I can see it works perfectly.

First I get:-
Velkommen tilbake til siden vår!...Vi håper du trives her!
Ditt siste besøk var fredag, 19 november, 2010 19:12:24

When I refrsh I get:-
Velkommen tilbake til siden vår!...Vi håper du trives her!
Ditt siste besøk var lørdag, 20 november, 2010 15:52:41

BTW, when posting here please follow the posting guidelines and wrap your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.

kijons
11-20-2010, 04:04 PM
Hello Philip and Old Pedant ;)

Now I have fix the last message :thumbsup:

I want to say thanks for all hjep to both;):D:o

ps: I only use javascript and not java on the page (I thought it was the same then :o)


Sincerely,

Jon
isprinsessa.com (http://isprinsessa.com)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum