# 3.21 Time and date

There is also a word in 4tH that will tell you what time and what date it is. With a little trouble ;). The word is called 'TIME' and it will tell you how many seconds have gone since January 1st, 1970.

Of course, this is a very low level word, but with a few calculations you can quickly make it of use. Like a timer that measures how long certain operation takes, like the execution of a colon-definition ("DO- SOME-WORD" in this case):

         time do-some-word time
         swap -
         ." Do-Some-Word took " . ." seconds." cr

You can also find out quickly how late it is:

         86400 constant s/day

         : sextal 6 base ! ;
         : :00 # sextal # decimal [char] : hold ;
         : time# <# :00 :00 #S #> type cr ;

         time s/day mod time# cr

Note that it doesn't know about daylight-saving! The day of the week is another thing you can easily calculate:

         7 constant days/week
         86400 constant s/day

         16 string day

         create weekdays
         " Thursday" ,
         " Friday" ,
         " Saturday" ,
         " Sunday" ,
         " Monday" ,
         " Tuesday" ,
         " Wednesday" ,

         weekdays
         time s/day / days/week mod
         th @' day copy
         count type cr

We haven't found a nice, small algorhythm to get you the full date. But if we do, you will find it here.