You are here: Re: Date formatting issue « All PHP « IT news, forums, messages
Re: Date formatting issue

Posted by Chris on 08/07/06 21:42

I am also having an issue with dates - I have a js calendar pop-up for
selecting the date to insert into a text box. It is formatted to show the
date as mm/dd/yyyy. However, the dates in the mySQL db show as yyyy-mm-dd,
and I have noted that when I try to input a new date into the database via
the form, all the db shows is 0000-00-00. Do I need to format the date some
way that it will go into the db the same way the db displays? Can I change
to format of the date field in the db? I researched this, but only came up
with ways to change the display in the Select results (works great for
printing out the date). Do I need to forget the calendar pop-up and just
have users input the date using an example format?

Thanks,
Chris


"Matt" <admin@clicktowalk.com> wrote in message
news:44d5ec87$1_2@mk-nntp-2.news.uk.tiscali.com...
>
> "J.O. Aho" <user@example.net> wrote in message
> news:4jl5bgF8i5rqU1@individual.net...
>> Matt wrote:
>>> I am attempting to format date values returned from a database
>>>
>>> // snippet of code
>>> while ($myrow = mysql_fetch_array($result)) {
>>> $offr_vsdate = $myrow[offr_vsdate];
>>> //
>>>
>>> If I echo the date 'as it comes'
>>> echo $offer_vsdate;
>>> I get the output: 2006-08-01
>>>
>>> But if I try to format the date as follows
>>> echo date("d/m/Y",$offer_vsdate);
>>> I get the output: 01/01/1970
>>
>> date don't take a string as argument, it needs a time value.
>> http://www.php.net/manual/en/function.date.php
>>
>> You can try with
>> echo date("d/m/Y",strtotime($offer_vsdate));
>>
>
> Many thanks, this worked a treat.
>
> Regards
> Matt
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация