Jump to content

What's the quickest most efficient way to change date format??


iPixel

Recommended Posts

$date = '03-02-2011';
echo strtoupper(date('d-M-Y', strtotime($date)));

 

THis returns 31-DEC-1969 and that is definately not the date in teh $date variable.

 

I've tested that locally, and it works fine with php 5.2.11. What do you get if you echo your $date variable before passing it through the functions?

I think this will serve best as to help me figure this out...

 

<?php
error_reporting(E_ALL);
ini_set('display_errors','On');

$start = $_GET['start']; //02-23-2011 is the date passed in this $_GET[];

//Convert dates to ORACLE format

$start2 = date_format($start, 'd-M-Y');
$end = strtoupper(date('d-M-Y', strtotime('today')));


echo $start;
echo " -=- ";
echo $end;

echo "<BR><BR>";

echo $start2; // Should be ORACLE FORMAT
echo " --- ";
echo $end;
?>

The - separator expects dd [.\t-] mm [.-] YY http://www.php.net/manual/en/datetime.formats.date.php

 

Like wise / expects the other:

 

echo date('M d Y',strtotime('02/20/1971'));
echo date('M d Y',strtotime('20-02-1971'));

 

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.