Re: Date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2007. 06. 20, szerda keltezéssel 09.35-kor Ron Piggott ezt írta:
> How do I break $start_date into 3 variables --- 4 digit year, 2 digit
> month and 2 digit day?
> 
> $start_year = ;
> $start_month = ;
> $start_day = ;
> 

depends on what format do you have $start_date in
if you have something like 2007-02-01 then you could use

$parts = explode('-', $start_date);
$start_year = $parts[0];
$start_month = $parts[1];
$start_day = $parts[2];

or you could use substr like

$start_year = substr($start_date, 0, 4);
$start_month = substr($start_date, 4, 2);
$start_day = substr($start_date, 7, 2);

and you have several other options also, like strtotime() etc ;)

greets
Zoltán Németh

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux