# Assign time value

**URL:** <https://community.unix.com/t/assign-time-value/152525>\
**Category:** Shell Programming and Scripting\
**Created:** [March 30, 2005, 3:29am UTC](https://community.unix.com/t/assign-time-value/152525 "2005-03-30T03:29:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phragix](https://community.unix.com/letter_avatar/phragix/32/5_5575768a8748004e209b776fc1b2916d.png) [@phragix](https://community.unix.com/u/phragix)\
**Post date:** [March 30, 2005, 3:29am UTC](https://community.unix.com/t/assign-time-value/152525/1 "2005-03-30T03:29:02Z")

</div>

I'm trying to monitor the traffic for few hours but still don't know how to make it possible. I try to set the value of time HH MM SS each into variables but for Hour, there's an error occurred as follow.

typeset -i hour=$(date +%H)  
typeset: 09: value too great for base (error token is "09")

"09" is my current hour time. Could you please suggest me how to solve this problem? Thank you very much for your kind advice.

P.S. this does not happen with Minutes and Seconds.

---

<div class="post-metadata">

**Author:** ![muthukumar](https://community.unix.com/letter_avatar/muthukumar/32/5_5575768a8748004e209b776fc1b2916d.png) [@muthukumar](https://community.unix.com/u/muthukumar)\
**Post date:** [March 30, 2005, 5:48am UTC](https://community.unix.com/t/assign-time-value/152525/2 "2005-03-30T05:48:25Z")

</div>

Which shell are you trying? IT is working on bash?

---

<div class="post-metadata">

**Author:** ![Perderabo](https://community.unix.com/user_avatar/community.unix.com/perderabo/32/27_2.png) [@Perderabo](https://community.unix.com/u/Perderabo)\
**Post date:** [March 30, 2005, 8:06am UTC](https://community.unix.com/t/assign-time-value/152525/3 "2005-03-30T08:06:30Z")

</div>

Actually it will happen with minutes and seconds if they are integers too. It just hasn't happened yet. Posix, in its wisdom, has decided that posix compliant shells must treat integers with a leading zero as octal.

Try this:

x=$(date +%H)  
typeset -i hour=${x#0}
