egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

convert timeago mysql

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
heman
Voice


Joined: 30 Dec 2006
Posts: 13

PostPosted: Fri Jan 19, 2007 6:43 pm    Post subject: convert timeago mysql Reply with quote

I need some help, i search around this forum, but couldnt find what im looking for.

Here goes:


Nicks are stored in a mysql database with the time the nick is added (datetime) like: 2007-19-01 20:01:02 (row is called "addtime")


To find how long ago the nick was stored the script use the folowing:

Code:

 set temp [mysqlsel $db "select *,SEC_TO_TIME(unix_timestamp(now()) - unix_timestamp(addtime)) as data from table WHERE .....




Now it returns someting like:

nick added to the db 17:50:57 ago
nick added to the db 25:50:57 ago
nick added to the db 339:50:57 ago
etc.


Im trying it will return the time after 24:00:00 like 1day 1hour 50min and 57 sec ago.

Same with weeks ,months, years


Any idea what i can add to the script to let it announce like this?

Thanks.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Jan 19, 2007 7:23 pm    Post subject: Reply with quote

Code:
proc timeAgo t {
 foreach {h m s} [split $t :] {
  set unixt [clock scan "$h hours $m minutes $s seconds ago"]
  break
 }
 duration [expr {[unixtime]-$unixt}]
}

Quote:

« Opposing » .tcl proc timeAgo t {foreach {h m s} [split $t :] {set unixt [clock scan "$h hours $m minutes $s seconds ago"];break} ; duration [expr {[unixtime]-$unixt}]}
« Bot » Tcl:
« Opposing » .tcl timeAgo 339:50:57
« Bot » Tcl: 2 weeks 3 hours 50 minutes 57 seconds

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
heman
Voice


Joined: 30 Dec 2006
Posts: 13

PostPosted: Sat Jan 20, 2007 10:41 am    Post subject: Reply with quote

that worked Smile

Thanks.


But now I have an other problem while testing the script Sad

So please take a look at:
http://forum.egghelp.org/viewtopic.php?p=69757#69757

Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber