Thread: MS Access dates

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    0
    Rep Power
    0
    ok.... I've just started learning PHP in the last 2-3 hours.

    Basically I have a database system I produced in ASP...and I'm converting it.

    everything is perfect.......apart from the date.
    It comes out as 1980-09-11 00:00:00 when I pull it from my access DB.

    How do i trim it down to 11-09-1980???? or other date formats... PHP seems to be lacking in this area..

    Any help is much appreciated..
    Cheers,
    steve

  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    What are you converting the ASP database to? another database?

    Got this from the PHP manual. It should convert your access timestamp into a unix timestamp. then use the date() function in PHP to format it.

    ereg("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})",$timestamp, $regs);
    echo date("D, j M Y, H:i:s",
    mktime($regs[4], $regs[5], $regs[6], $regs[2],$regs[3], $regs[1]));

    or this:

    function mysql_to_epoch ($datestr) {
    list($year,$month,$day,$hour,$minute,$second) = split("([^0-9])",$datestr);
    return date("U",mktime($hour,$minute,$second,$month,$day,$year));
    }

    you could also look into the strtotime() function.

    strtotime Parse about any english textual datetime description into a UNIX timestamp

    find these and other great functions in the PHP manual, vicinity,
    http://www.php.net/manual/ref.datetime.php

    ---John Holmes...

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions...
    *
    * PHP Manual. www.php.net/manual
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter
    *************************************************************
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    0
    Rep Power
    0
    No I'm converting a web site thats on an NT box. It uses ASP to access database content.

    I'm just want to convert it (the pages) to PHP so I can run it on non-NT setups.

    Isn't there a function to trim the last digits(time) of the variable????

  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    You can use a substring function to just get the last part, if that's what you want.

    $time = substr($datbase_time,-8);

    If you turn it into a unix timestamp and use date() though, you can format the time however you want, the date however you want, or both...read the manual on date() please.

    ---John Holmes...
  8. #5
  9. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Colchester, England
    Posts
    131
    Rep Power
    14
    Alternatively if the time isn't needed at all change the way the date is stored in Access.

    If you unable to change it to only store the date without time, go with John's solution above.

    Andy J

    [This message has been edited by eaamj01 (edited November 14, 2000).]

Similar Threads

  1. SPs in Access 2000 (SQL) / Crosstab problem / returning dataset
    By michaeldallas in forum MS SQL Development
    Replies: 1
    Last Post: September 1st, 2005, 01:41 PM
  2. mysql - MS access linked tables has locked me from changing anything
    By alexmasters in forum Database Management
    Replies: 2
    Last Post: May 15th, 2004, 04:17 AM
  3. ms access - mySQL interaction question
    By alexmasters in forum MySQL Help
    Replies: 0
    Last Post: December 6th, 2003, 06:09 AM
  4. ACCESS - filtering dates
    By AliCat in forum Database Management
    Replies: 3
    Last Post: November 25th, 2003, 05:33 PM
  5. createObject Vs as New Keyword
    By imran189 in forum Visual Basic Programming
    Replies: 3
    Last Post: November 11th, 2003, 07:19 PM

IMN logo majestic logo threadwatch logo seochat tools logo