Jump to content

PHP Date Conversion


websteve

Recommended Posts

Thanks for the reply, but what if I want to display the converted data to the screen? I'm trying this code (below) that searches all rows between 2 dates, using STR_TO_DATE().  Doesn't seem to work correctly, but besides getting this to work right, the end result I want is to echo the converted date to the display.  Sorry for sounding confused, I used to work in PHP a few years ago and am just starting to get back into it.

 

This is the code I have now. I know it is not correct.

 

$datefilter = '%m/%d/%y/';

$Res_pur = "SELECT * FROM Purchasing WHERE Date BETWEEN STR_TO_DATE('$beg_date', '$datefilter') AND STR_TO_DATE('$end_date', '$datefilter')";

$Results_pur = mysql_query($Res_pur)or die('Could Not Access Purchasing Table: ' . mysql_error());

while ($Results_pur_Arr = mysql_fetch_array($Results_pur)) {

echo '<tr><td>'. $Results_pur_Arr['ID'] . '</td><td>'. $Results_pur_Arr['Date'].'</td><td>'. $Results_Arr['Item'].'</td><td>'.$Results_Arr['Description'].'</td></tr>';

}

Link to comment
https://forums.phpfreaks.com/topic/210704-php-date-conversion/#findComment-1099154
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.