#native_company# #native_desc#
#native_cta#

Easy dates

By jonseddon
on August 6, 2006

Version: 1.0

Type: Sample Code (HOWTO)

Category: Calendars/Dates

License: GNU General Public License

Description: A short piece of code to help move dates and times around. Store the date and time in one column in mysql and use this to help display it however you want.
My first post and first explode() function. A very proud moment.

Let's assume that the date goes into a column as
follows

$date = (date ("Y-m-d H:i:s")); 

Mysql_query("select * ...");
the date being in the array as:-
$date = $row['date'];

//begin

$dte = explode("-", $date);{      // breaks the array
    $Year = $dte[0];              // the year
    $month = $dte[1];             // the month
    $dt = $dte[2];                // the day + time
    $d_te = explode (" ", $dt);{  // explode again
    $day = $d_te[0];              // The day
    $time = $d_te[1];             // The time
    }
    $final_date = $day.'/'.$month.'/'.$Year;   
    }

//end

$final_date is now a nice European format. Squiff it around to :-

$final_date = $month.'/.$day.'/'.$Year;

for the yanks and $tim is the time.