Re: How to convert a date to an int?(Need help as soon as possible)
| From: | Joe Stump | Date: | Sat, 03 Mar 2001 00:15:44 +0000 |
| Subject: | Re: How to convert a date to an int?(Need help as soon as possible) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-42407@lists.php.net to get a copy of this message | ||
Well if you have a consistent format (like Month Day, FullYear) then you could
do this:
function get_unix_stamp($date)
{
$months = array('Jan' => 1,'Feb' => 2,
'Mar' => 3,'Apr' => 4,
'May' => 5,'Jun' => 6,
'Jul' => 7,'Aug' => 8,
'Sep' => 9,'Oct' => 10,
'Nov' => 11,'Dec' => 11);
$foo = explode(' ',$date);
$month = $months[$foo[0]];
$day = str_replace(',',$foo[1]);
$year = $foo[2];
return mktime(0,0,0,$month,$day,$year);
}
--Joe
On Fri, Mar 02, 2001 at 06:58:45PM -0500, Fang Li wrote:
> Hi, All,
> I am stucked here.Would you please help as soon as you can?
>
> LiveDate = "Mar 12,2001"
>
> how to convert it to a int?
>
> mktime(0,0,0,?,?,?)
> Because the LiveDate is changable, I could't put a 3,12,2001 in the mktime.
>
> Thanks a lot.
>
> Fang
>
>
> --
> 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
--
-------------------------------------------------------------------------------
Joe Stump, PHP Hacker, joestump98@yahoo.com -o)
http://www.miester.org http://www.care2.com
/\\
"It's not enough to succeed. Everyone else must fail" -- Larry Ellison _\_V
-------------------------------------------------------------------------------