Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

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

 
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
 
Sheriff
Posts: 24291
55
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.
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!