Hi all,
I want to add a minute to present time.
E.g:
if present time is 09:55, I want to make it 09:56.
Please help!!
I tried below script
#!/bin/ksh
timeut=`date -u '+%R'`
let timeut1=$timeut + 1
echo "timeut1 = $timeut1"
Regards
Prashant:confused:
nua7
August 19, 2008, 5:43am
2
Try this:
perl -e '@d=localtime time() + 600; printf "%02d:%02d%s\n",$d[2]%12,$d[1],("AM","PM")[$d[2]/12]'
It adds 10 minutes to the current time.
nua7:
Try this:
perl -e '@d=localtime time() + 600; printf "%02d:%02d%s\n",$d[2]%12,$d[1],("AM","PM")[$d[2]/12]'
It adds 10 minutes to the current time.
............
(perl is not supported here)
.can u gimee the answer in pure korn shell scripting
try TZ..
first check this echo "$TZ"
it shows something like this
IST - 5:30 i guess
then TZ=IST - 5:31(not sure try + or -)
then type date you may get one min forward time
then change back the TZ to normal..
Thanks for reply...
but
MY SERVER TIME ZONE IS MST.
SO echo "$TZ" shows me MST7 as output.
so this will not help!!
Here I am converting MST time into GMT by date -u '+%R' (eg:15:44).
further I dont know how to increment(eg. 15:44 to 15:45).
are you using HP-UX??
then gothrough tztab man page once.. it may help..
timehh=`date -u '+%H'`
timemm=`date -u '+%M'`
curr_time="$timehh:$timemm"
timemm=`expr $timemm + 1`
new_time="$timehh:$timemm"
echo "$curr_time === $new_time"
this won't work if current time is 12:59 and so on.. because after addition it becomes 12:60 instead of 13:00
Thanks a lot palsevlohit_123 !!!!
It helped me a lot..
it really helped you?? did you tried when min is 59??
Yes,...It really helped me.
i used a condition for that.(when min=59)incrementing hour...etc..
Regards
P
If you have ksh93 you can use the %T option to printf to manipulate the date
$ newtime=$(printf "%(%H:%M)T\n" "now + 1 minute")
Thanks for reply..
but
......its not working in my machine....
Any other solution ...?
prashant43:
Hi all,
I want to add a minute to present time.
E.g:
if present time is 09:55, I want to make it 09:56.
Please help!!
I tried below script
#!/bin/ksh
timeut=`date -u '+%R'`
let timeut1=$timeut + 1
echo "timeut1 = $timeut1"
Regards
Prashant:confused:
Finally using the below for my query..........Thanks for all who ever replied and gave their valuable answers...
#!/bin/ksh
timehh=`date -u '+%H'`
timemm=`date -u '+%M'`
if test $timemm -eq 59
then
timehh=`expr $timehh + 1`
timemm=`expr $timemm - 1`
fi
curr_time="$timehh:$timemm"
timemm=`expr $timemm + 1`
new_time="$timehh:$timemm"
echo "$curr_time === $new_time"
Regards
Prashant
Here you go:
$ date
Tue Aug 19 08:42:03 CDT 2008
$ TZ=CDT+4:59 date
Tue Aug 19 08:43:09 CDT 2008