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

Posted by werner huysmans on 08/20/06 08:17

I'm using a small JavaScript Library
/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/
* ------------------------------------------------------------------
*
* The DHTML Calendar, version 0.9.6 "Keep cool but don't freeze"
*
* Details and latest version at:
* http://dynarch.com/mishoo/calendar.epl
*
* This script is distributed under the GNU Lesser General Public License.
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
*/
This allows the user to open a calendar and pick a date, you can pre-format
it, before sending it away.
If dates are important, I'd advice checking the validity before inserting in
a database.



"Chris" <designerNOSPAM@centurytel.net> wrote in message
news:eb8c47$lto$1@news01.intel.com...
>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

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