Click to See Complete Forum and Search --> : Need help with time dependent script


Liquid Snake
02-20-2003, 07:26 PM
Recently I've been playing around with mplayer and my TV card. I want to make a script that would prompt me for the channel, time and duration of a show to record. I know how to do that, the only problem I'm having is getting the time of day variable. How would I get the system time, preferably in seconds after midnight, into a $time variable?

The Kooman
02-21-2003, 12:11 AM
How 'bout this? ...


#!/bin/bash

# just in case you have it aliased/defined to something else (like I do)!
unalias date
unset date

# 0-23
hours=`date +'%k'`

# 0-59
mins=`date +'%M'`

# 0-59
secs=`date +'%S'`

# be careful about leaving the spaces between each variable/number.
time=$[ $hours * 3600 + $mins * 60 + $secs ]

echo "time = $time"


HTH

error27
02-21-2003, 12:11 AM
echo $(( $(date +%H)*60*60 ))
echo $(( $(date +%M)*60 ))
echo $(date +%S)

secs_since_midnight=$(( $(date +%H)*60*60 + $(date +%M)*60 + $(date +%S) ))

error27
02-21-2003, 12:16 AM
blast...

If I had been a minute earlier and my post would have been usefull.