|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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... |
|
#3
|
|||
|
|||
|
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! |
|
#4
|
||||
|
||||
|
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... |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
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. |
|
#7
|
||||
|
||||
|
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 |
|
#8
|
|||
|
|||
|
thanks! i thought that documentation was for developers and such.
thanks again, night. |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Easy question! SYSDATE() works....is there a SYSTIME()? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|