Re: convert yyyy/mm/dd to mm/dd/yyyy, how?
| From: | George Pitcher | Date: | Mon, 14 Jan 2002 09:33:19 +0000 |
| Subject: | Re: convert yyyy/mm/dd to mm/dd/yyyy, how? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15748@lists.php.net to get a copy of this message | ||
Sander,
I'm also in Europe but here in the UK we prefer dd/mm/yyyy and I've cobbled
together a couple of functions to handle this for me.
function dbdate($input)
{
$today = explode("-",$input);
$month = $today[1];
$day = $today[2];
$year = $today[0];
$p_date = $day . "/" . $month . "/" . $year ;
return $p_date;
}
function revdate($input)
{
$today = explode("/",$input);
$day = $today[0];
$month = $today[1];
$year = $today[2];
$revdate = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-"
.
str_pad($day, 2, "0", STR_PAD_LEFT);
return $revdate;
}
I've stored these in a file which I include and any call to the db to
display dates uses the dbdate() function and if I want to insert or update a
date then I use the revdate() function.
There are probably better ways to do this.
Hope this helps.
George in Edinburgh
----- Original Message -----
From: "Sander Peters" <S.Peters@Visionnet.nl>
To: <php-general@lists.php.net>; <php-db@lists.php.net>
Sent: Sunday, January 13, 2002 7:56 PM
Subject: [PHP-DB] convert yyyy/mm/dd to mm/dd/yyyy, how?
> Hello everybody,
>
> convert yyyy/mm/dd to mm/dd/yyyy, how?
>
> MYSQL does everything in yyyy/mm/dd.
> I live in the Netherlands and we are use to the format dd/mm/yyyy.
>
> What's the best way to display it as mm/dd/yyyy in a table on a query?
>
> My first idea whas to split the date up in vars in php and then print
> the vars in the way I like it
> Is this a bad idea? Or are there better sollutions?
>
> Thanx in advance for answering!
>
>
>
> --
> Met vriendelijke groet / With Greetings,
>
> Sander Peters
>
> site: http://www.visionnet.nl/
> email: mailto:s.peters@visionnet.nl
> webmail: mailto:sanderpeters@yahoo.com
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com