> -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of uday > Sent: Thursday, February 02, 2012 8:57 AM > To: r-help@r-project.org > Subject: Re: [R] time conversion from second to Y M D H M S format > > Dear Uwe , > Thanks for reply > I have tried format function that u suggested (format(time_t1, "%Y %m > %d %H > %M %S") and I got > format(time_t1, "%Y %m %d %H %M %S") > [1] "126230400" "126252000" "126273600" "126295200" "126316800" > "126338400" > > > I think something is not working correct. > >
You are right something is not working correctly. But you haven't shown what you did from beginning to end, so we don't know what that something might be. Try this > time <-c( 126230400, 126252000, 126273600, 126295200, 126316800, 126338400) > time_t1<- as.POSIXlt(time, origin="2005-01-01", tz="GMT") > time_t1 [1] "2009-01-01 00:00:00 GMT" "2009-01-01 06:00:00 GMT" [3] "2009-01-01 12:00:00 GMT" "2009-01-01 18:00:00 GMT" [5] "2009-01-02 00:00:00 GMT" "2009-01-02 06:00:00 GMT" > format(time_t1, "%Y %m %d %H %M %S") [1] "2009 01 01 00 00 00" "2009 01 01 06 00 00" "2009 01 01 12 00 00" [4] "2009 01 01 18 00 00" "2009 01 02 00 00 00" "2009 01 02 06 00 00" > Does that not do what you wanted? Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 ______________________________________________ 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.