| View previous topic :: View next topic |
| Author |
Message |
heman Voice
Joined: 30 Dec 2006 Posts: 13
|
Posted: Fri Jan 19, 2007 6:43 pm Post subject: convert timeago mysql |
|
|
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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Jan 19, 2007 7:23 pm Post subject: |
|
|
| 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 |
|
 |
heman Voice
Joined: 30 Dec 2006 Posts: 13
|
|
| Back to top |
|
 |
|