Month counts from 0 in POSIXlt objects, so that April is month 3 in your
example, January being month 0.

Year counts from 1900 in POSIXlt objects, so that 2005 should return as 105
in your example.

All of the other fields in POSIXlt should return values that you might
expect them to a priori. Keep an eye on daylight savings time adjustments if
they apply in your time zone.

On Tue, Mar 1, 2011 at 12:01 PM, Seth W Bigelow <sbigelow@fs.fed.us> wrote:

> I would like to use POSIX classes to store dates and extract components of
> dates. Following the example in Spector ("Data Manipulation in R"), I
> create a date
>
> > mydate = as. POSIXlt('2005-4-19 7:01:00')
>
> I then successfully extract the day with the command
>
> > mydate$day
> [1] 19
>
> But when I try to extract the month
>
>  > mydate$mon
> [1] 3
>
> it returns the wrong month. And mydate$year is off by about 2,000 years.
> Am I doing something wrong?
>
> Dr. Seth  W. Bigelow
> Biologist, USDA-FS Pacific Southwest Research Station
> 1731 Research Park Drive, Davis California
> sbigelow@fs.fed.us /  ph. 530 759 1718
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
___________________________
Luke Miller
Postdoctoral Researcher
Marine Science Center
Northeastern University
Nahant, MA

	[[alternative HTML version deleted]]

