Jump to content


Photo

date format question


  • Please log in to reply
4 replies to this topic

#1 tribal

tribal
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationNYC

Posted 23 October 2003 - 06:30 PM

hi, i got a DB field that is a DATETIME format and is automatically entered when a user registers. how do i change format from 2003-10-22 10:05:06

to something like 10/22/2003 10:05 ??

can i modify the existing mysql format?

#2 nabeel21

nabeel21
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 24 October 2003 - 12:52 AM

From MySQL manual:

MySQL retrieves and displays DATETIME values in \'YYYY-MM-DD HH:MM:SS\' format.


I had the same issue and wanted to store the date in mysql in a custom format. I defined the column to be a TEXT instead of DATETIME and populated it with PHP
[php:1:44d99b4a40]<?php
$datetime = date(\"d/m/Y h:i\");
?>[/php:1:44d99b4a40]

Hope it helps.

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 25 October 2003 - 07:26 AM

... and in doing so. lost the ability to sort it into sequence, use comparison operators or use any of the dozens of date/time functions provided.

Leave it as it is in the database and format it on output.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 02 May 2008 - 04:34 PM

I was searching the same problem. I would like to change it on output but i can't find any functions that will do that. They only format the time as it is now. I want to take any date from the DATE on mysql and change it to eg. Jan. 11, 2005 .. can anyone help me find a function that will do this, thanks!

#5 PFMaBiSmAd

PFMaBiSmAd
  • Staff Alumni
  • Advanced Member
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 02 May 2008 - 06:13 PM

Use the mysql DATE_FORMAT() function in your query, you can find it in the date and time function section of the mysql manual.
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users