You are here: Re: Calendar and date functions « All PHP « IT news, forums, messages
Re: Calendar and date functions

Posted by Michael Fesser on 09/04/07 11:49

..oO(Otis)

>PHP is driving me mad with their idiotic way of dealing with dates and
>date conversions - unless I'm the idiot.
>
>Here's what I need:
>
>Let's assume the date is $d = "09/03/1951" - Sep 3, 1951
>
>How do I get just the year from a date like Sep 3, 1951?
>How do I get just the day from a date like Sep 3, 1951?
>How do I get just the month from a date like Sep 3, 1951?

Internally PHP works with Unix timestamps. Use strtotime() to turn your
date into such a timestamp, then use whatever date function you like,
e.g.

$date = getdate(strtotime('09/03/1951'));

Now $date will be an array with all the informations you want:

Array
(
[seconds] => 0
[minutes] => 0
[hours] => 0
[mday] => 3
[wday] => 1
[mon] => 9
[year] => 1951
[yday] => 245
[weekday] => Monday
[month] => September
[0] => -578451600
)

Micha

 

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

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