MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 23rd, 2000, 04:50 AM
Nightspirit Nightspirit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 10 Nightspirit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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!

Reply With Quote
  #2  
Old September 23rd, 2000, 09:08 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 21 h 11 m 18 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
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...

Reply With Quote
  #3  
Old September 23rd, 2000, 07:20 PM
Nightspirit Nightspirit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 10 Nightspirit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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!

Reply With Quote
  #4  
Old September 24th, 2000, 04:26 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 21 h 11 m 18 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
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...

Reply With Quote
  #5  
Old September 25th, 2000, 12:57 AM
Nightspirit Nightspirit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 10 Nightspirit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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.

Reply With Quote
  #6  
Old September 25th, 2000, 01:12 AM
Nightspirit Nightspirit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 10 Nightspirit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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.

Reply With Quote
  #7  
Old September 25th, 2000, 06:37 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate FolderFolding Points: 73048 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 21 h 11 m 18 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
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

Reply With Quote
  #8  
Old September 25th, 2000, 12:17 PM
Nightspirit Nightspirit is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 10 Nightspirit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks! i thought that documentation was for developers and such.

thanks again, night.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Easy question! SYSDATE() works....is there a SYSTIME()?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT