Jump to content

[SOLVED] Time Format!!


iceman023

Recommended Posts

I can't believe its taking me this long to figure out how to go from

 

2009-05-04 00:00:00

 

to 05/04/09

 

I have all the dates that a photo was upload to the database in a field called date. I just want to change the display of the format from the database.

Some please help!

 

Pic of the database attached

 

[attachment deleted by admin]

Link to comment
Share on other sites

IS this what you ment or no...

$results = mysql_query("
SELECT * FROM Photos 
WHERE Published = 'no' 
AND DATE_FORMAT(`Date`, '%m/%d/%y') AS `Date` FROM Photos
ORDER BY ID DESC LIMIT $page, $limit");
while ($data = mysql_fetch_array($results))
{

Link to comment
Share on other sites

Or is it this one

 


$numresults = mysql_query("
SELECT * FROM Photos 
WHERE Published = 'no' 
AND DATE_FORMAT(`Date`, '%m/%d/%y') AS `Date` FROM Photos
ORDER BY ID DESC"); // the query.
$numrows = mysql_num_rows($numresults); // Number of rows returned from above query.
if ($numrows == 0){
echo("No results found matching your query - $query"); // bah, modify the "Not Found" error for your needs.
exit();}

Link to comment
Share on other sites

Sorry kinda new to this..

 


$numresults = mysql_query("
SELECT DATE_FORMAT(`Date`, '%m/%d/%y') AS `Date`,
* FROM Photos	
WHERE Published = 'no' 
ORDER BY ID DESC"); // the query.
$numrows = mysql_num_rows($numresults); // Number of rows returned from above query.
if ($numrows == 0){
echo("No results found matching your query - $query"); 
exit();}

Link to comment
Share on other sites

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in....

 

 

 

 

in php MyAdmin sql it say....

 

 

Error

SQL query: 

 

SELECT DATE_FORMAT( `Date` , '%m/%d/%y' ) AS `Date`

FROM Photos, *

FROM Photos

WHERE Published = 'no'

ORDER BY ID DESC

LIMIT 0 , 30

 

MySQL said: 

 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM Photos   

WHERE Published = 'no'

ORDER BY ID DESC

LIMIT 0, 30' at line 2

Link to comment
Share on other sites

Sorry this one...

 

 

Error

SQL query: 

 

SELECT DATE_FORMAT( `Date` , '%m/%d/%y' ) AS `Date` ,

* FROM Photos

WHERE Published = 'no'

ORDER BY ID DESC

LIMIT 0 , 30

 

MySQL said: 

 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM Photos   

WHERE Published = 'no'

ORDER BY ID DESC

LIMIT 0, 30' at line 2

Link to comment
Share on other sites

I hate to be a pain in the ass but

 

I have this

 

SELECT * , DATE_FORMAT( `Date` , '%m %d %y' ) AS `Date` 
FROM Photos
WHERE Published = 'no'
ORDER BY ID DESC 
LIMIT 0 , 30 

 

and the output is "2009-05-04"

shouldnt it be.... "05.04.09"

 

IF not how do i get "05.04.09"

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.