• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to change the date,Time format after accessing it from the database

 
malik ge
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to know how to change the Date and Time format, after accessing it from the database.
I am getting the current date and time by:


In the database the datatype of dateTime column is datetime.
I am able to insert the current date and time into the database in "yyyy-mm-dd hh:mm:ss" format.

When I access it from the database, it returns the date and time in "yyyy-mm-dd hh:mm:ss" format,

How can change it into "hh:mm:ss dd-mm-yyyy" format???
Thanks
 
Paul Clapham
Sheriff
Pie
Posts: 20978
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already know how to format a Date using any format you like. In fact you just posted an example of how to do it there. That's how you do it.

But don't say things like "the database formats a Date in such a way". It may have a default that it uses if a client asks it to display a Date in some string format, but that doesn't mean you have to do that. Don't do that. Get the column from the database as a Date and format it yourself. Which you already know how to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic