Reply to Re: formmating dates?

Your name:

Reply:


Posted by ZeldorBlat on 11/11/07 16:09

On Nov 11, 10:15 am, "mantrid" <ian.dan...@virgin.net> wrote:
> "mantrid" <ian.dan...@virgin.net> wrote in message
>
> news:9xCZi.21578$6v.8195@newsfe2-gui.ntli.net...> Im reading a csv file with php and getting a date in the form 30/09/07
>
> > Which I am trying to insert into a mysql table which has the field
> formatted
> > as yyyy-mm-dd hh:mm:ss
> > I cant get it to insert the field remains blank
> > How do I do this?
>
> I was able to work around the problem using
>
> $datebits = explode("/", $dateandtime);
> $dateandtime = date('Y-m-d
> H:i:s',mktime(00,00,00,$datebits[1],$datebits[0],$datebits[2]));
>
> However, if there is a simple single function I can use, or if anyone knows
> a better way please let me know as users may not use the dd/mm/yyy format
> but could use something along the lines of dd-mm-yyyy or any other style.

Use strtotime() and date():

date('Y-m-d', strtotime($dateandtime));

[Back to original 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

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