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

Posted by Tom on 09/04/07 17:41

On Tue, 04 Sep 2007 00:38:22 -0700, Otis wrote...
>
>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?
>
>I have never been able to get PHP to deal properly with the years since
>it seems to have the stupid habit of deciding for itself whether a year
>is 2000 something or 1900 something. It apparently only wants to deal
>with 2-digit years.
>
>Here is what I have done in the past when I needed a FULL date:
>
> if ($inyear >= 2000)
> {
> $utdatenow = strftime("%d.%m.20%y", mktime($inhours, $inmins,
>$insecs, $inmonth, $inday, $inyear));
> }
> else
> {
> $utdatenow = strftime("%d.%m.19%y", mktime($inhours, $inmins,
>$insecs, $inmonth, $inday, $inyear));
> }
>
>How cumbersome!!!
>
>Isn't PHP/UNIX smart enough to know what the 4-digit year is without me
>having to jump through hoops?
>
>In Visual Basic it was simple:
>
>yr$ = Year("09/03/1951") gave me 1951
>dy$ = Day("09/03/1951") gave me 3
>mo$ = Month("09/03/1951") gave me 9
>
>Why isn't PHP as straight-forward?
>
>
>Thank you.
>
>
>Otis


Might check either of there at the PHP site. I believe the top one will give you
a string of text with the information you request. The second would give you an
array you can probably get more use out of...

http://www.php.net/manual/en/function.date.php
http://www.php.net/manual/en/function.getdate.php

Tom
--
NewsGuy Takes Usenet Cellular!
Download newsgroup MP3's to your Cell or PDA
Free Trial - http://newsguy.com/cellphone.htm

 

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

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