[R] Fwd: as.POSIXlt() Function

Vasantha Kumar Kesavan info.vasukv at gmail.com
Thu Oct 23 08:56:16 CEST 2014


PST8PDT is the valid timezone in my machine and I have verified it.

I am followed your suggestion. there is no difference in the output.


*> Sys.setenv(TZ="America/Los_Angeles");*
*> Sys.getenv("TZ");*
*                   TZ *
*"America/Los_Angeles" *
*> as.POSIXlt(Sys.Date());*
*[1] "2014-10-22 UTC"*
*> as.POSIXct(Sys.Date());*
*[1] "2014-10-21 17:00:00 PDT"*
*> as.POSIXct(Sys.time());*
*[1] "2014-10-22 23:53:39 PDT"*
*> as.POSIXlt(Sys.time());*
*[1] "2014-10-22 23:53:43 PDT"*


[root at srv1 ~]# ls /usr/share/zoneinfo
Africa      Asia       Canada   Cuba   EST      Factory  GMT0
Hongkong  Iran         Japan      Mexico   Navajo   Poland      PRC
 ROK        Universal  W-SU
*America*     Atlantic   CET      EET    EST5EDT  GB       GMT-0      HST
    iso3166.tab  Kwajalein  Mideast  NZ       Portugal    *PST8PDT*
 Singapore  US         zone.tab
Antarctica  Australia  Chile    Egypt  Etc      GB-Eire  GMT+0      Iceland
  Israel       Libya      MST      NZ-CHAT  posix       right    Turkey
UTC        Zulu
Arctic      Brazil     CST6CDT  Eire   Europe   GMT      Greenwich  Indian
   Jamaica      MET        MST7MDT  Pacific  posixrules  ROC      UCT
 WET
[root at srv1 ~]#

Thanks
Vasanth

On Thu, Oct 23, 2014 at 9:45 AM, David Winsemius <dwinsemius at comcast.net>
wrote:

>
> On Oct 22, 2014, at 7:46 PM, Jeff Newmiller wrote:
>
> > Because PST8PDT probably is not a valid TZ on your operating system. Try
> "America/LosAngeles"
>
> For me (on a Mac) it has an intervening dash:
>
> > Sys.timezone(location = TRUE)
> [1] "America/Los_Angeles"
>
> However, on a mac the system returns a differnt results:
>
> >  Sys.getenv("TZ")
> [1] ""
>
> --
> David.
>
> >
> ---------------------------------------------------------------------------
> > Jeff Newmiller                        The     .....       .....  Go
> Live...
> > DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
> Go...
> >                                      Live:   OO#.. Dead: OO#..  Playing
> > Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> > /Software/Embedded Controllers)               .OO#.       .OO#.
> rocks...1k
> >
> ---------------------------------------------------------------------------
> > Sent from my phone. Please excuse my brevity.
> >
> > On October 22, 2014 2:35:55 AM PDT, Vasantha Kumar Kesavan <
> info.vasukv at gmail.com> wrote:
> >> Hi,
> >>
> >> I am a new R user and also not sure about the below concern is really a
> >> bug,
> >>
> >> My concern are listed below,
> >>
> >> Look at the below example, when Sys.Date () is called within the
> >> as.POSIXlt
> >> () function. Why it is displaying only the date value and the timezone
> >> is
> >> selected to UTC even though the TZ variable is set to "PST8PDT".  I
> >> could
> >> not see this kind of behavior with as.POSIXct () function.
> >>
> >> This is happening in both LINUX 32 and 64 bit operating system.
> >>
> >>
> >> Example:
> >>
> >>> version
> >>              _
> >> platform       i386-redhat-linux-gnu
> >> arch           i386
> >> os             linux-gnu
> >> system         i386, linux-gnu
> >> status
> >> major          2
> >> minor          10.0
> >> year           2009
> >> month          10
> >> day            26
> >> svn rev        50208
> >> language       R
> >> version.string R version 2.10.0 (2009-10-26)
> >>> Sys.setenv(TZ="PST8PDT");
> >>> Sys.setenv(ORA_SDTZ="PST8PDT");
> >>>
> >>> Sys.getenv("TZ");
> >>      TZ
> >> "PST8PDT"
> >>> Sys.getenv("ORA_SDTZ");
> >> ORA_SDTZ
> >> "PST8PDT"
> >>>
> >>> as.POSIXct(Sys.Date());
> >> [1] "2014-10-20 17:00:00 PDT"
> >>> c(as.POSIXct(Sys.Date()));
> >> [1] "2014-10-20 17:00:00 PDT"
> >>>
> >>> as.POSIXlt(Sys.Date());
> >> [1] "2014-10-21 UTC"
> >>> c(as.POSIXlt(Sys.Date()));
> >> [1] "2014-10-20 17:00:00 PDT"
> >>>
> >>> as.POSIXct(Sys.time());
> >> [1] "2014-10-21 20:59:23 PDT"
> >>> c(as.POSIXct(Sys.time()));
> >> [1] "2014-10-21 20:59:23 PDT"
> >>>
> >>> as.POSIXlt(Sys.time());
> >> [1] "2014-10-21 20:59:23 PDT"
> >>> c(as.POSIXlt(Sys.time()));
> >> [1] "2014-10-21 20:59:23 PDT"
> >>>
> >>
> >> Thanks
> >> Vasanth
> >>
> >>      [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> R-help at 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.
> >
> > ______________________________________________
> > R-help at 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.
>
> David Winsemius
> Alameda, CA, USA
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list