andretanguy Posted May 11, 2007 Share Posted May 11, 2007 hey! i have FPDF (php script that generates pdf files from variables). I can get the from date and to date to show, but they show like this: e.g.: 2006-12-20 now im trying to do this but its not working: <? $curDate = array( '01' => 'January', '02' => 'Feruary', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December' ); $frmdate = $row['formdate']; $frmdate = explode("-", $frmdate); $todate = $row['todate']; $todate = explode("-", $todate) $pdf->SetFont( 'Arial', '', 9 ); $pdf->Cell( 30, 5, "Available:", 0, 0, 'L' ); $pdf->Cell( 0, 5, "$curDate[$frmdate[1]]; $frmdate[2];, $frmdate[0]; to $curDate[$todate[1]]; $todate[2]; , $todate[0]; ", 0, 1, 'L' ); ?> originally, the FROM date is referenced as: $l_formdate the TO date is referenced as: $l_todate i know there was a typo in the from date and it became formdate so dont worry about that. Any help would be amazing Cheers André Link to comment https://forums.phpfreaks.com/topic/50912-solved-php-date-conversion-to-readable-format/ Share on other sites More sharing options...
kenrbnsn Posted May 11, 2007 Share Posted May 11, 2007 You want to use a combination of the strtotime() and date()[/functions]: <?php $frmdate = date('F j, Y', strtotime($row['formdate'])); $todate = date('F j, Y',strtotime($row['todate'])); $pdf->SetFont( 'Arial', '', 9 ); $pdf->Cell( 30, 5, "Available:", 0, 0, 'L' ); $pdf->Cell( 0, 5, $frmdate . ' to ' . $curDate, 0, 1, 'L' ); ?> Ken Link to comment https://forums.phpfreaks.com/topic/50912-solved-php-date-conversion-to-readable-format/#findComment-250442 Share on other sites More sharing options...
redbullmarky Posted May 11, 2007 Share Posted May 11, 2007 take a look at strtotime() for converting the date into a timestamp, and then date() or strftime() for formatting the date to taste. edit: beat me to it Link to comment https://forums.phpfreaks.com/topic/50912-solved-php-date-conversion-to-readable-format/#findComment-250445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.