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

Posted by Steve on 09/04/07 13:31

> unless I'm the idiot.

which is totally the case. don't bash php because *you* don't get it. rtfm!

> Here's what I need:
>
> Let's assume the date is $d = "09/03/1951" - Sep 3, 1951

$d = strtotime('09/03/1951'); // which won't work on windows server

> How do I get just the year from a date like Sep 3, 1951?

echo date('Y', $d);

> How do I get just the day from a date like Sep 3, 1951?

echo date('d', $d);

> How do I get just the month from a date like Sep 3, 1951?

echo date('m');

really hard, ain't it?!!!

> 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.

ALL software languages have to ASSUME what year you want when you give it a
two-digit year, moron! AND MOST ALL OF THEM use 38 as the magic number. if
below or eq 38, 20 + two-digit is used...if > 38, 19 + two-digit. RTFM !!!

> 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!!!

yep...never mind it being stupid.

> Isn't PHP/UNIX smart enough to know what the 4-digit year is without me
> having to jump through hoops?

lol...aren't you smart enough to read a fucking manual?

> In Visual Basic it was simple:

ahhhh...NOW THAT EXPLAINS IT!!!

> 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?

it is, AND it is *easier* because you only need ONE function in the first
place in order to get the result(s) you want!

> Thank you.

piss off.

 

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

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