SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,666
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    grabbing the current date and the ip address

    I have a mysql table with the following 2 data fields

    ...
    `regdate` date NOT NULL,
    `regip` varchar(30) NOT NULL default '',
    .,.,

    Is this the correct way to capture both the current date (YYYY-MM-DD) and the IP address.
    PHP Code:
    $date curdate();
    $ip $_SERVER['REMOTE_ADDR']; 
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,666
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    or is this a good way to caapture the current datew
    PHP Code:
    $date date("Ymd"); 
    "Oh, and Jenkins--apparently your mother died this morning."

  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Location
    Trinidad and Tobago
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lukeurtnowski, MySQL expects its dates to be formatted yyyy-mm-dd. Because of this you're going to have to format the date for input. For example:

    $date = date("Y-m-d");
    $ip = $_SERVER['REMOTE_ADDR'];

    echo $date;
    echo $ip;

    //create sql query for insert

    Best of luck.

  4. #4
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,666
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    thanks
    "Oh, and Jenkins--apparently your mother died this morning."


Bookmarks

Posting Permissions

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