Programming :  Student Freelance Forum For Work Experience Builders' (CertificationPoint) The fastest message board... ever.
 
PHP-Easy dates
Posted by: adcertpoint (Moderator)
Date: April 29, 2020 04:26PM

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"winking smiley);

Mysql_query("select * ..."winking smiley;
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.

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.