|
Posted by Ed on 10/13/44 11:28
Marcos wrote:
> I'm developing one application that it must support many types of
> dates, e.g:
>
> 2005-09-03 // yyyy-mm-dd
> 03/09/2005 // dd/mm/dd
>
> The administrator will be able of the modify the style using the formal
> mode aaaa, dd, mm...
>
> But I need already format the date for the save in database mysql
> (aaaa-mm-dd) and later
> transform again to transform again for the date that the administrator
> chose.
Hi there,
Where database storage is concerned, use a format that is suitable for
comparisons/calculations, such as 'yyyymmdd'.
After you retrieve records from your database you can use PHP's date()
function in combination with mktime() to output any format you like.
For example, let's say you have '20050929' in your database record...
// The following outputs "Thursday, September 29, 2005"
echo date("l, F d, Y", mktime(0, 0, 0, substr($row['date'], 4, 2),
substr($row['date'], -2), substr($row['date'], 0, 4)));
// The following outputs "09/29/2005"
echo date("m/d/Y", mktime(0, 0, 0, substr($row['date'], 4, 2),
substr($row['date'], -2), substr($row['date'], 0, 4)));
....etc.
Hope that helps you, good luck.
Ed
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Navigation:
[Reply to this message]
|