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

    Join Date
    Sep 2000
    Posts
    10
    Rep Power
    0
    Hello there!

    The question is..well...the topic.

    SYSDATE() works, but does SYSTIME() exist? NOW() returns a funny string.....which i really do not understand.

    and what do i do to split the date, which is 22-09-2000, to 22 September 2000? In other words, is there a similar split() function like Perl has?

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

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    Are you trying to store/retrieve the current date, or store/retrieve a user entered date?

    The manual says NOW() and SYSDATE() are the same.

    select date_format(NOW(),'d M Y');

    will return the current date formatted like 22 September 2000

    not sure exactly what you want to do.

    ---John Holmes...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    10
    Rep Power
    0
    Hi!

    Hey I'm actually trying to make myself a personal guestbook thru php and mysql; serves me as a tutorial, the hard way.

    well, ive got $date as DATE, and $time as TIME (variable types). Once, before, they needn't be INSERTed...mysql seems to automatically write them in for each new entry.

    but doing that now, seems to return only 00-00-0000 and 00:00:00. So I had to resort to including the $date and $time values manually.

    i may be able to use CURTIME and CURDATE i guess...but i would like to have them recorded as they are on the users' system time...not the standard GMT time thingy.

    PROBLEM 2:
    In viewbook.php ...
    If I were to use CURDATE, an echo would return 24-09-2000. How do I make it display 24 September 2000?

    echo row["date"];

    echo row["date('d M y')"]; ??? <-- is that the way to do it?

    PROBLEM 3:
    Is there anyway I can acquire the remote host? REMOTE_ADDR works, for IPs....butu I would like to also learn how to acquire hostnames. REMOTE_HOST doesn't work...how?

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

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    Solution 1:

    You don't need a seperate date and time column. just make a timestamp, it savest them both. Mysql only automatically updates only one timestamp column (date and time are both variations of timestamp).

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    mysql> create table test (id int, today timestamp, var text);
    Query OK, 0 rows affected (0.00 sec)

    mysql> insert into test (id,var) values (10,'text');
    Query OK, 1 row affected (0.00 sec)

    mysql> select * from test;
    +------+----------------+------+
    | id | today | var |
    +------+----------------+------+
    | 10 | 20000924050549 | text |
    +------+----------------+------+
    1 row in set (0.00 sec)
    mysql> select id, date_format(today,'%H:%i:%s') as time, date_format(today,'%e %M %Y') as date, var from test;
    +------+----------+-------------------+------+
    | id | time | date | var |
    +------+----------+-------------------+------+
    | 10 | 05:05:49 | 24 September 2000 | text |
    +------+----------+-------------------+------+
    1 row in set (0.00 sec)
    [/code]

    Read the manual and look at the date time functions.

    Solution 2: See solution 1. Once you do the select and fetch_row, you would display '24 September 2000' by
    echo $row["date"];
    and show the time by
    echo $row["time"];

    Solution 3:
    Love those manuals.

    gethostbyaddr
    (PHP3 <= 3.0.16, PHP4 )

    gethostbyaddr -- Get the Internet host name corresponding to a given IP address
    Description

    string gethostbyaddr (string ip_address)


    Returns the host name of the Internet host specified by ip_address. If an error occurs, returns ip_address.

    See also gethostbyname().

    Hope that helps.

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

    Join Date
    Sep 2000
    Posts
    10
    Rep Power
    0
    PROBLEM 1:
    Wow man thanks a lot! I shall try it out soon!

    PROBLEM 2:
    Urr..so how do I write it out?

    $usersHost = string gethostbynaame(strin ip_address);

    OR

    $userHost = gethostbyname();

    ?

    I'm sorry but I don't know what a manual is....err...rather I don't know what manual you are talking about. Can I download one? Is it "documentation"?

    I'm doing this and hoping that I can learn by using as much free resources as I can.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    10
    Rep Power
    0
    woohoo! thanks man! it works! both of them!

    select ... date_format(entrystamp,'date_format(entrystamp,'%H:%i:%s') as time,date_format(entrystamp,'%e %M %Y') as date from table01 ORDER by id DESC;

    that works and this too:

    $host = gethostbyaddr($ip);

    thanks a lot SepodatiCreations! I really appreciate it!

    -Night.
  12. #7
  13. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    You should always check for an online manual. In this case, PHP and MySQL, the online manuals are part of what makes them so great. 90% of your answers can be answered by a little searching through the manuals.

    MySQL www.mysql.com
    Manual www.mysql.com/documentation/mysql/bychapter/

    PHP www.php.net
    Manual www.php.net/manual

    Enjoy...

    ---JH
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    10
    Rep Power
    0
    thanks! i thought that documentation was for developers and such.

    thanks again, night.

Similar Threads

  1. Easy Question PROFTPD
    By steral in forum FTP Help
    Replies: 1
    Last Post: February 12th, 2004, 07:00 PM
  2. easy ActionScript syntax question
    By lapidus in forum Flash Help
    Replies: 3
    Last Post: January 27th, 2004, 06:22 AM
  3. Question - easy solution?
    By Quality in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 12:57 PM

IMN logo majestic logo threadwatch logo seochat tools logo