Re: how to convert a string into a date format ?????

From: Date: Wed, 10 Oct 2001 07:07:34 +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-70586@lists.php.net to get a copy of this message
Keep in mind, however, that a unix_timestamp has a range starting at Jan 1, 1970. If you are working only with current dates, then this will not be a problem, but if you are working with historical dates, such as a persons age, then do not go with the unix_timestamp. -Jason Garber IonZoft.com At 06:50 AM 10/10/2001 +0000, Philip Olson wrote:
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 -- 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


« previous php.general (#70586) next »