• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 27590
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
A tiny monkey bit me and I got tiny ads:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic