Jump to content

[SOLVED] PHP date conversion to readable format


andretanguy

Recommended Posts

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é

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

 

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.