Jump to content

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


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'));

 

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.