Results 1 to 3 of 3

Thread: Equivalent date functions in PHP ?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212

    Lightbulb Equivalent date functions in PHP ?

    Hi there,

    Got another question about PHP. I've succeeded in converting most of my ASP functions to PHP, but I don't understand quite well how date works.

    Suppose i have a string, say $strTmp = '2002-01-12', how can i tell PHP this is a date ( Like CDate() ) and then extract month, day, year from it ?

    Thanks in advance !
    Regards,

    El-Nino

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you can explode that string at the "-" and then use the month day and year or you can use date like so

    $the_date = date(Y,m,d);

    or
    $year = date(Y);
    $month = date(m);
    $year = date(d);

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Equivalent date functions in PHP ?

    Originally posted by eL_NiNo
    Hi there,

    Got another question about PHP. I've succeeded in converting most of my ASP functions to PHP, but I don't understand quite well how date works.

    Suppose i have a string, say $strTmp = '2002-01-12', how can i tell PHP this is a date ( Like CDate() ) and then extract month, day, year from it ?

    Thanks in advance !
    The PHP documentation can be a valuable resource: http://www.php.net/

    You can find information on the date function here: http://www.php.net/manual/en/function.date.php

    As for telling PHP it's a date, that doesn't matter. There aren't specified variable types in PHP. Just as long as it's the right format for date, PHP will recognize it.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width