Re: Date
| From: | Zoltán Németh | Date: | Wed, 20 Jun 2007 13:51:46 +0000 |
| Subject: | Re: Date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257488@lists.php.net to get a copy of this message | ||
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