HTML Help Forum Index HTML Help
Please Search for the answer to your question before asking it! Thanks.
 

Date not correctly displayed in FF
Post a Reply to this Topic Ask a New Question
Click here to go to the original topic
       HTML Help Forum Index -> Javascript
View previous topic :: View next topic  
Author Message
Samuel Jong



Joined: 06 Jan 2008
Posts: 111

Posted: Mon Aug 24, 2009 12:14 pm     Date not correctly displayed in FF  

How to make the date correctly displayed in FF?
I have no problem in IE.

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/home.dwt" codeOutsideHTMLIsLocked="false" -->
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>新华校友网站 - Sin Hoa Alumni Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="mm_health_nutr.css" type="text/css">
<script language="JavaScript" type="text/javascript">
<!--
<!-- Display date -->
var enabled = 0; today=new Date();
var day; var date; var centry;
if(today.getDay()==0) day = "星期日"
if(today.getDay()==1) day = "星期一"
if(today.getDay()==2) day = "星期二"
if(today.getDay()==3) day = "星期三"
if(today.getDay()==4) day = "星期四"
if(today.getDay()==5) day = "星期五"
if(today.getDay()==6) day = "星期六"
centry="";
if (today.getYear()<2000 ) centry = "19" ;
date1 = centry + (today.getYear()) + "年" + (today.getMonth() + 1 ) + "月" + today.getDate() + "日 " ;
date2 = "" + day ;
<!-- End of date -->
quartzy



Joined: 26 Dec 2007
Posts: 477

Posted: Sat Sep 05, 2009 3:22 pm     re date  

Try this code, it works for me, thought you will need to change the time format, if local does not work in your area.
Code:  var curDateTime = new Date()
  document.write(curDateTime.toLocaleString())
Samuel Jong



Joined: 06 Jan 2008
Posts: 111

Posted: Sat Sep 05, 2009 5:22 pm      

Which code should I delete and change with this:
var curDateTime = new Date()
quartzy



Joined: 26 Dec 2007
Posts: 477

Posted: Sun Sep 06, 2009 2:12 am     re  

Put the code into a separate .js file and then link to it, so you would remove all of your existing code. The way you link to it, is like this:
<script type="text/javascript" src="date.js"></script>
placing this in the place that you want the date to show. Inbetween span or p tags.
naming the correct path to the js file. This can then be styled with css to how you want it.
Samuel Jong



Joined: 06 Jan 2008
Posts: 111

Posted: Sun Sep 06, 2009 1:12 pm      

It means that I couldn't display the date in Chinese?
 
 
DARFUR
HOSTING / DESIGN
MAKE MONEY

       HTML Help Forum Index -> Javascript
Page 1 of 1


Powered by phpBB Search Engine Indexer
Powered by phpBB 2.0.19 © 2001, 2002 phpBB Group