PDA

View Full Version : British Date Format Help (PHP)



bossmode
10-27-2004, 05:59 PM
I have installed the Ultra Apps portal system.
http://www.ultraapps.com/freecommunitywebportal.html

My site is:

http://ukasian.co.uk


I have difficulty in changing the date formats to British (dd/mm/yy).

The code I think I need tol change is in common.php:

function now()
{
return date("Y-m-d G:i:s");
}

function vdate($ldate)
{
$ldate = str_replace(":","-",$ldate);
$ldate = str_replace(" ","-",$ldate);
list ($year, $month, $day, $hour, $minute) = explode("-", $ldate);
if ($newdate = mktime ($hour, $minute, 0, $month, $day, $year)) {
if (@date("H-i", $newdate) == "00-00")
return @date("m/d/y", $newdate);
else
return @date("m/d/y h:i A", $newdate);
}
}

function sdate($ldate)
{
list ($year, $month, $day, $hour, $minute) = explode("-", $ldate);
$newdate = mktime (0, 0, 0, $month, $day, $year);
return date("m/d/y", $newdate);
}

function datetodb($edate)
{
return date("Y-m-d H:i:s",strtotime($edate));
}


I have tried the simple things like changing m/d/y to d/m/y... This causes problems in save and retrive from database (changes numbers around).

The database is in MYSQL, Field is a standard DateTime.

Any help would be much appriciated.

Amitkrathi
10-28-2004, 03:29 AM
Insert date in database in y-m-d format through php. You can select(retrieve) date using date function in mySQL in your format through sql query. check mySQL Manual to do this.

<Mod Edit paulhiles - removed irrelevant promotional links >http://www.indastro.com[/url]

mushroom
10-28-2004, 12:45 PM
To start with "now();" is a standard function and you should not try to redefine it.
Datetime is mysql is stored "YYYY-MM-DD hh:mm:ss"
But if you use timestamps in mysql you have built in php function for formating your display "string_date(string format,integer timestamp);"

string_date("d/m/Y h:i A",$timestamp_var);