wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Date not getting displayed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Date not getting displayed" Watch "Date not getting displayed" New topic
Author

Date not getting displayed

prakash ke
Greenhorn

Joined: Apr 20, 2011
Posts: 7
I have a html page wherein i want to the date. If I open the html file with any browser it's displaying correctly. But when I put it in server it's not working.

My script goes like this

<P>Payment is due on <script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
//-->
</script>.</P>

Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

Actually I'm not really sure about this but does not everything between <!-- and --> is not comment?
Anyways, your javascript is not valid. Every line of code in javascript must end with semicolon, I can clearly see that your's doen't.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Zandis Murāns wrote:Actually I'm not really sure about this but does not everything between <!-- and --> is not comment?

Does not effect the JavaScript and it is not needed.

Zandis Murāns wrote:Anyways, your javascript is not valid. Every line of code in javascript must end with semicolon, I can clearly see that your's doen't.

This is incorrect, JavaScript does not need semicolons.

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
prakash ke wrote:But when I put it in server it's not working.


Any errors?

Are you cached? Clear the cache and try again.

Eric
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

Eric Pascarello wrote:
Zandis Murāns wrote:Anyways, your javascript is not valid. Every line of code in javascript must end with semicolon, I can clearly see that your's doen't.

This is incorrect, JavaScript does not need semicolons.

Eric

I agree with you now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date not getting displayed