This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Old posts that have not been replied to for several years.
bazn
Voice
Posts: 12 Joined: Sun Jul 04, 2004 11:55 am
Post
by bazn » Mon Jul 19, 2004 7:20 am
I there, i have short question,
I have a DB in which is a date stored in unixtime, checking back how old it is works fine, but now i want to implement something like a routine which calculates if the time of the object on the databae is older than a definied time here is my try, but it didn't work :ü
Code: Select all
if {$what == "DVDR"} {
set pred_release [lindex $outp 0]
set pred_section [lindex $outp 1]
set pred_time [lindex $outp 2]
set pred_reason [lindex $outp 5]
set pred_dbtime [unixtime ]
incr pred_dbtime -$pred_time
set pred_time2 $pred_time
set pred_ago [duration $pred_dbtime]
set back_dvdr "120"
incr back_dvdr -$pred_dbtime
set back_calc [duration $back_dvdr]
set pred_time3 [clock format $pred_time2 -format "%D %T"]
if {[string tolower $pre_channel1] == [string tolower $chan] && $back_calc < $pred_ago} {
so anyone can help me with this?
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Mon Jul 19, 2004 8:47 am
Set the bouth times in the same format, I mean the current time and the old time. Also, have a look
here and please do use the search function..
Once the game is over, the king and the pawn go back in the same box.
bazn
Voice
Posts: 12 Joined: Sun Jul 04, 2004 11:55 am
Post
by bazn » Mon Jul 19, 2004 9:47 am
hi, thx for your answer but my problem is not to calculate the time format, it is how i must define the variable "back_dvdr" to the right format maybe i have a little understanding problem atm (it's hot outside)
cheers
greenbear
Owner
Posts: 733 Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway
Post
by greenbear » Mon Jul 19, 2004 10:03 am
If I understand you correctly you want to check if something is older than 2 hours, and you have the unixtime for when it was written to your db.
So just take current unixtime - 'the time it was written to the db', and see if its bigger than 7200 (2hours in seconds)
Code: Select all
if {[expr [unixtime] - $pred_time] > 7200} {
# it pre'd more than 2 hours ago.
}
bazn
Voice
Posts: 12 Joined: Sun Jul 04, 2004 11:55 am
Post
by bazn » Mon Jul 19, 2004 10:28 am
um yes thx works fine
can u explain me how i calculate the unixtime?
cheers
greenbear
Owner
Posts: 733 Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway
Post
by greenbear » Mon Jul 19, 2004 10:50 am
'unixtime' is the number of seconds since 00:00:00 01/01/1970
So, 1min = 60sec, 1hour = 3600sec, 1 day = 86400 ..you get the idea...
bazn
Voice
Posts: 12 Joined: Sun Jul 04, 2004 11:55 am
Post
by bazn » Mon Jul 19, 2004 3:56 pm
yes works fine much thx