View Full Version : jscript to show month / year to comply with Firefox Mozilla
multimediamkt
May 9th, 2006, 11:12 PM
may 10th 2006
Iīve employed the script at the bottom of this page to show month/year ;
It works fine with IE , Opera and Netscape if "Display like IE" menu is selected ;
is there a way to modify this script to render it compatible with Firefox or even another script that
works with all main browsers ?
<script type="text/javascript">
//<![CDATA[
var n = new Date(), m = ['Jan', 'Feb', 'March', 'April', 'May', 'June', 'July', 'August', 'September',
'October', 'November', 'December'];
document.write(m[n.getMonth()] + ' ' + n.getFullYear());
//]]>
</script>
CriTiCeRz
May 9th, 2006, 11:19 PM
Try this:
<script language="JavaScript">
<!--
var now = new Date();
var days = new Array(
'Sunday','Monday','Tuesday',
'Wednesday','Thursday','Friday','Saturday');
var months = new Array(
'January','February','March','April','May',
'June','July','August','September','October',
'November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;}
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear()));
document.write(today);
//-->
</script>
Note: I did not make this script. Source:
http://www.webreference.com/js/scripts/basic_date/
mpr
May 10th, 2006, 04:11 PM
I use the same one. That works in all three browsers (IE, Firefox, Opera).
multimediamkt
May 10th, 2006, 11:05 PM
Thatīs strange I inserted the code as it is among the head but it does not work ;
CriTiCeRz
May 10th, 2006, 11:44 PM
Put this in a file called date.js
// ***********************************************
// AUTHOR: WWW.CGISCRIPT.NET, LLC
// URL: http://www.cgiscript.net
// Use the script, just leave this message intact.
// Download your FREE CGI/Perl Scripts today!
// ( http://www.cgiscript.net/scripts.htm )
// ***********************************************
var now = new Date();
var days = new Array(
'Sunday','Monday','Tuesday',
'Wednesday','Thursday','Friday','Saturday');
var months = new Array(
'January','February','March','April','May',
'June','July','August','September','October',
'November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;}
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear()));
document.write(today);
And put this between your head tags:
<script language="JavaScript" src="date.js"></script>
multimediamkt
May 12th, 2006, 01:44 AM
pardon my previous post , I should be forty winks , the script was supposed to be inserted somewhere into the body tag.
I tried to modify the script to show only month & year (I do not need the date) ;
it has not worked .
any hint ?
cheers
CriTiCeRz
May 12th, 2006, 04:25 PM
Why don't you use PHP, it's a lot easier...
Ankou
May 12th, 2006, 06:01 PM
It might help if you post the HTML and the JavaScript that you're currently working with. We could sit here and keep guessing as to why it's not working, but with code to work off of it's easier to troubleshoot.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.