![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Generating files with time interval of fifteen minutes | aajan | Shell Programming and Scripting | 0 | 09-24-2007 10:54 PM |
| how to display time in minutes n seconds... | santy | Shell Programming and Scripting | 1 | 08-23-2006 07:18 AM |
| Help setting PS1 prompt to include current time | m223464 | Shell Programming and Scripting | 3 | 11-28-2005 09:59 PM |
| Substituting variable with current time | jhansrod | Shell Programming and Scripting | 4 | 11-20-2005 05:20 PM |
| How can I create a file with current time - 60 minutes | DaveyTN | Shell Programming and Scripting | 4 | 10-05-2005 05:17 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Adding # minutes to current time...
Hi all,
Looking for a way to add lets say 10 minutes to the current time output should look like 7:15 AM or 7:15 PM. I know that gdate could do this for me but unfortunately its not available on the system I'm working on. So if any one know any way I can accomplish this using the date command it would be great. Thanks, --GT |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
$ date
Thu Jun 21 22:12:54 IST 2007 Code:
$ perl -e 'print scalar localtime time + 600' |
|
#3
|
|||
|
|||
|
Code:
#!/bin/ksh
add_min()
{
perl -e '
$tm = $ARGV[0];
$tm *= 60;
($sec,$min,$hour,$day,$mon,$yr,$wday,$yday,$dntcare)=localtime(time + $tm);
printf("%2d:%2d:%2d\n", $hour, $min, $sec);
' $1
}
add_min 10
|
|
#4
|
||||
|
||||
|
I really like this one liner, perl -e 'print scalar localtime time + 600' however the format of the output needs to look like 1:39 PM.... can this be done with perl?
P.S. Thanks for the quick responses... Last edited by gptavares; 06-21-2007 at 11:07 AM. |
|
#5
|
||||
|
||||
|
Try:
perl -e '@d=localtime time() + 600; printf "%02d:%02d%s\n",$d[2]%12,$d[1],("AM","PM")[$d[2]/12]' |
|
#6
|
||||
|
||||
|
Perfect, thanks Perderabo... and everyone else...
|
|
#7
|
|||
|
|||
|
gnu awk
Code:
awk 'BEGIN{print strftime("%c %p",systime()+600)}'
|
|||
| Google The UNIX and Linux Forums |