For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > October 2004 > Formatting date from MySql









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Formatting date from MySql
oeyvind toft

2004-10-20, 3:56 pm

Is there a function in PHP that takes a date(an integer datatype from MySql)
as argument
and formats it ?

Oeyvind
--
http://home.online.no/~oeyvtoft/ToftWeb/




Harrie Verveer

2004-10-20, 3:56 pm

yes
http://nl3.php.net/manual/en/function.date.php

oeyvind toft wrote:
> Is there a function in PHP that takes a date(an integer datatype from MySql)
> as argument
> and formats it ?
>
> Oeyvind

Ninjaboy

2004-10-20, 8:55 pm

Just use
SELECT UNIX_TIMESTAMP(date) from your_sql_table;

then do the $formated = date("l dS of F Y h:i:s A",$sql[date]);


"Harrie Verveer" <newsgroup{remove-this}@harrieverveer.com> wrote in message
news:7fednT-Y-8O64OvcRVnyvg@zeelandnet.nl...[color=darkred]
> yes
> http://nl3.php.net/manual/en/function.date.php
>
> oeyvind toft wrote:


oeyvind toft

2004-10-20, 8:55 pm

Perfect !

Thanks Ninjaboy, just what I was looking for...

Oeyvind

--
http://home.online.no/~oeyvtoft/ToftWeb/



"Ninjaboy" <ninjaboy@yourunderground.com> skrev i melding
news:JCzdd.8187$6q2.823@newssvr14.news.prodigy.com...
> Just use
> SELECT UNIX_TIMESTAMP(date) from your_sql_table;
>
> then do the $formated = date("l dS of F Y h:i:s A",$sql[date]);
>
>
> "Harrie Verveer" <newsgroup{remove-this}@harrieverveer.com> wrote in

message
> news:7fednT-Y-8O64OvcRVnyvg@zeelandnet.nl...
>
>



Chris Hope

2004-10-20, 8:55 pm

Ninjaboy wrote:

[color=darkred]
[color=darkred]
> Just use
> SELECT UNIX_TIMESTAMP(date) from your_sql_table;
>
> then do the $formated = date("l dS of F Y h:i:s A",$sql[date]);


The other way to do it, and to avoid using proprietary database functions
that are not portable to other database systems, is to do the following:

date('format here', strtotime($date_in_dbformat));

where $date_in_dbformat is the date and time returned from the database.

For more info refer to the manual:
http://www.php.net/date
http://www.php.net/strtotime

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
oeyvind toft

2004-10-20, 8:55 pm


"Chris Hope" <blackhole@electrictoolbox.com> skrev i melding
news:1098311223_28048@216.128.74.129...

> The other way to do it, and to avoid using proprietary database functions
> that are not portable to other database systems, is to do the following:
>
> date('format here', strtotime($date_in_dbformat));
>
> where $date_in_dbformat is the date and time returned from the database.




Even better...

Thanks Chris

Oeyvind


http://home.online.no/~oeyvtoft/ToftWeb/


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com