Re: how to convert a string into a date format ?????
| From: | Philip Olson | Date: | Wed, 10 Oct 2001 06:50:00 +0000 |
| Subject: | Re: how to convert a string into a date format ????? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70585@lists.php.net to get a copy of this message | ||
Also consider the strtotime() function, it'll give you the unix timestamp
of this string. Example :
$date_str = '2001-10-25';
print strtotime($date_str); // 1003968000
Using it with date() can be like :
print date('F d, Y',strtotime($date_str)); // October 25, 2001
If applicable, let your database do such conversions as it'll be more
efficient that way.
regards,
Philip Olson
On Wed, 10 Oct 2001, Jason G. wrote:
>
> list($year, $month, $day) = explode('-', '2001-10-25');
> echo $year;
> echo $month;
> echo $day;
>
> OR
>
> $aData = explode('-', '2001-10-25');
> echo $aData[0]; //year
> echo $aData[1]; //month
> echo $aData[2]; //day
>
> -Jason Garber
> IonZoft.com
>
> At 10:36 AM 10/10/2001 +0530, sagar N Chand wrote:
> >hi all,
> >
> >i have a string like this "2001-10-25".
> >I want to convert this into a date format. ie i want
> >to get only the month or only the date or only the year from this
> >string without using string manupulations.
> >
> >is there any way out. i've gone thru the manual.
> >
> >/sagar
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>