# Working of Date[]

Date[] returns the current date of local system, Date[1] returns {2012, 11, 15, 17, 41, 0.3161629}, Date[2] returns {2012, 11, 15, 18, 41, 0.3161629}, and Date[3] returns {2012, 11, 15, 18, 41, 0.3161629} and so on and why? Also, I tried this code

    a = DateList[] (*line 1*)
a = a + {0, 0, 0, 1, 0, 0} (*Line 2*)


After executing Line 2 for a few more times I get {2012, 11, 15, 25, 41, 0.3161629}. How can I fix this as I want to use increment time by 1 hour or 30 min in a For loop

-
Date[] is deprecated; any reason why you need to use it instead of DateList[]? – J. M. Nov 15 '12 at 16:49
From the Date documentation "Date has been superseded by DateList since Version 6.0." and it says first argument is timezone, i.e. how many hours away from GMT. I recommend using DateList – ssch Nov 15 '12 at 16:50
Can i use date as loop counter – Soum Nov 15 '12 at 16:55
And use DatePlus when adding to a date (see DateDifference too) – ssch Nov 15 '12 at 17:07
Yeah i got it. Thanks – Soum Nov 15 '12 at 17:12

Date is deprecated. According to the Mathematica 5 documentation, Date[z] returns the time in time zone z.

You probably want to use DateList to accomplish the kinds of things you are describing. The following will add an hour and a half to the current date:

date = DateList[]
DatePlus[date, 3/48]

(* Out:
{2012, 11, 15, 12, 7, 3.572165}
{2012, 11, 15, 13, 37, 3.572}
*)


This works because DatePlus[date, n] adds n days to date and $1.5$ hours is $3/48$ of a day. There's probably a better way to specify the units; you could consult the DatePlus documentation to find out.

-