Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can we get current time  RSS feed

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we get current time and date on webpage through jsp or html.
Thanks
 
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use JavaScript Date object,
or java.util.Date, and java.text.SimpleDateFormat to create it on server, and send as plain HTML.
 
Ranch Hand
Posts: 1084
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will not recommend using javascript date because it depends on client machine.

user time of Web server/Database server
 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think it is better to get value of current time from server's current time.
You can get using GregorianCalendar or System.currentTimeMillis...

Hope this helps...

thanks
daniel
 
Ranga Reddy shreya
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnaks
 
Popeye has his spinach. I have this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!