Questions tagged [posixlt]

Class `POSIXlt` more conveniently represents the result of Class `POSIXct` (the number of seconds since the beginning of 1970) as a numeric vector of more directly accessable values for seconds, minutes, hours, days, months, years etc.

Class POSIXct represents the (signed) number of seconds since the beginning of 1970 (in the UTC time zone) as a numeric vector. Class "POSIXlt" is a named list of vectors representing

sec - 0–61: seconds.

min - 0–59: minutes.

hour - 0–23: hours.

mday - 1–31: day of the month

mon - 0–11: months after the first of the year.

year - years since 1900.

wday - 0–6 day of the week, starting on Sunday.

yday - 0–365: day of the year.

isdst - Daylight Saving Time flag. Positive if in force, zero if not, negative if unknown.

zone - (Optional.) The abbreviation for the time zone in force at that time: "" if unknown (but "" might also be used for UTC).

gmtoff - (Optional.) The offset in seconds from GMT: positive values are East of the meridian. Usually NA if unknown, but 0 could mean unknown.

151 questions
26
votes
3 answers

Problems with dplyr and POSIXlt data

I have a problem. I downloaded data and tranformed dates into POSIXlt format df<-read.csv("007.csv", header=T, sep=";") df$transaction_date<-strptime(df$transaction_date, "%d.%m.%Y") df$install_date<-strptime(df$install_date, "%d.%m.%Y") df$days<-…
Slavka
  • 1,070
  • 4
  • 13
  • 28
14
votes
2 answers

Convert Factor to Date/Time in R

This is the information contained within my dataframe: ## minuteofday: factor w/ 89501 levels "2013-06-01 08:07:00",... ## dDdt: num 7.8564 2.318 ... ## minutes: POSIXlt, format: NA NA NA I need to convert the minute of day column to a date/time…
Michelle
  • 193
  • 1
  • 1
  • 6
12
votes
2 answers

What do "ct" and "lt" (in POSIXct and POSIXlt) mean?

I am interested, what "ct" and "lt" (in POSIXct and POSIXlt) mean. Are they some kind of abbreviations? E.g., does "ct" mean "calendar time" and "lt" something else?
GegznaV
  • 4,938
  • 4
  • 23
  • 43
12
votes
2 answers

How to join two dataframes by nearest time-date?

I have 2 data sets, each containing a date-time value in POSIXlt format, and some other numeric and character variables. I want to combine both data sets based on the date-time column. But the date stamps of both data sets do not match, so I need to…
user2223405
  • 343
  • 1
  • 3
  • 6
8
votes
3 answers

Remove timezone during POSIXlt Conversion in R

I have a column in my dataframe as datetime (factor) with the values as "15-10-2017 16:41:00". I wanted this data to be converted as "2017-10-15 16:41:00". When i try to convert this, I'm getting the timezone also as output. I tried using tz="",…
Simbu
  • 85
  • 1
  • 1
  • 6
8
votes
1 answer

Converting chr "00:00:00" to date-time "00:00:00"

My question comes from this question. The question had the following character string. x <- "2007-02-01 00:00:00" y <- "02/01/2007 00:06:10" If you try to convert this string to date-class object, something funny happens. This is a sample from…
jazzurro
  • 23,179
  • 35
  • 66
  • 76
7
votes
1 answer

In R, why do I get one millisecond difference between POSIXct and POSIXlt?

This snippet options(digits.secs=3) s<-"12:00:00.188" fmt<-"%I:%M:%OS" print(strptime(s,fmt)) print(as.POSIXct(strptime(s,fmt))) gives this textual output: [1] "2017-09-12 00:00:00.188 CEST" [1] "2017-09-12 00:00:00.187 CEST" while I expect the…
Alessandro Jacopson
  • 18,047
  • 15
  • 98
  • 153
6
votes
0 answers

Why does strptime result in an infinite list when using View in RStudio?

Disclaimer: The title of the question might be wrong, because I don't know what causes this behaviour. The 'issue' is that viewing a POSIXlt object in RStudio viewer shows an infinite linked list, as far as I can determine. MWE: x <-…
marts
  • 658
  • 1
  • 10
  • 15
6
votes
3 answers

Extraction of POSIXlt component runs fine in R 3.4.4, but errors in R 3.5.0. Why?

1) R version 3.4.4 (2018-03-15) my.timedate <- as.POSIXlt('2016-01-01 16:00:00') # print(attributes(my.timedate)) print(my.timedate[['hour']]) [1] 16 2) R version 3.5.0 (2018-04-23) my.timedate <- as.POSIXlt('2016-01-01 16:00:00') #…
6
votes
1 answer

Comparing POSIXlt object with date string the right thing?

I recently came across R code that compared a POSIXlt date object with a date string. as.POSIXlt.date("2007-02-02") >= "2007-02-01" [1] FALSE The result, surprisingly at least for me, was FALSE. I was expecting that the POSIXlt object would be…
farhanhubble
  • 476
  • 3
  • 18
5
votes
3 answers

Converting to Local Time in R - Vector of Timezones

I have a set of data from across the US that I am trying to convert into local time for each "subject". I have UTC timestamps on each event and have converted those into POSIXct format, but every time I try to include a vector of tz = DS$Factor or…
Shorthand
  • 176
  • 6
4
votes
2 answers

How to read date time string with full weekday and month names?

So I'm trying to read a date from a long date string. I'm not real sure what I'm doing wrong here. lines = "Friday, November 30, 2018, 8:00 AM" as.POSIXlt(lines, format = "%A, %B %m, %Y, %I, %p")
Charles Stangor
  • 292
  • 7
  • 21
4
votes
1 answer

dplyr group_by throw error on variable not in the function

I am using R 3.4.0 and dplyr 0.5.0 (I also have tested using R 3.3.3 and I have the same error). I have been using this following type of code regularly in the past (even yesterday!) but for some reasons it creates an error today. For instance, I…
4
votes
2 answers

"unlist" removes class in list elements (POSIXlt)

I have an object that is a multi-level list, where all elements are of class POSIXlt: [[1]] [1] "2015-07-16 GMT" "2015-07-16 GMT" "2015-07-16 GMT" "2015-07-16 GMT" "2015-07-15 GMT" [6] "2015-07-15 GMT" "2015-07-15 GMT" "2015-07-15 GMT" "2015-07-15…
Marc in the box
  • 11,769
  • 4
  • 47
  • 97
4
votes
1 answer

differences between subsetting POSIXlt and POSIXct in R

DATA v1 <- c("2015-01-05 15:00:00", "2015-01-05 15:45:00", "2015-01-05 15:00:30") OPERATIONS v2 <- strptime(v1, '%Y-%m-%d %H:%M:%S') str(v2) POSIXlt[1:3], format: "2015-01-05 15:00:00" "2015-01-05 15:45:00" "2015-01-05 15:00:30" v3 <- v2[!v2$min] …
jpinelo
  • 1,414
  • 5
  • 16
  • 28
1
2 3
10 11