This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

How to get current date in JS

 
angelin precilla
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,
I need to dispaly the current date time in a jsp page.
I am calling javascript for calender.
My code is

Its not working .
Anyone help me out ....

In java it works fine..
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
JavaScript has little to do with Java, despite its name. You can't use Java classes like SimpleDateFormat in JS. If the format you're getting from "new Date().toString()" is not sufficient, you'll need to do string manipulation to transform it.

Alternatively, Java code in the JSP page can embed the formatted date string inside the script:


[ November 02, 2007: Message edited by: Ulf Dittmer ]
 
angelin precilla
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Report post to moderator
How to perform localization in date time using jsp
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
Let's continue the discussion about localization in this duplicate thread.
 
    Bookmark Topic Watch Topic
  • New Topic