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
1
vote
1 answer

R - subsetting by date

i'm trying to subset a large dataframe by date field ad facing strange behaviour: 1) find interesting time interval: > ld[ld$bps>30000000,] Date.first.seen Duration Proto Src.IP.Addr Src.Pt Dst.IP.Addr Dst.Pt Tos Packets …
Dvalin Swamp
  • 315
  • 1
  • 2
  • 9
1
vote
2 answers

How do I extract only the time parameters from Datetime variable in R?

In a R dataframe I have time variable. The data is in the format %a-%b-%d %H:%M:%S. for e.g., 2015-03-23 20:00:00 I want to get the following data only 20:00:00 I have created a table basis the above said variable and trying to make a line…
Apricot
  • 2,925
  • 5
  • 42
  • 88
1
vote
0 answers

Why does as.POSIXlt return NA for some valid dates?

I can't figure out why I'm getting TRUE from this is.na test: is.na(as.POSIXlt(x = "03/09/2014 2:00", format = "%m/%d/%Y %H:%M")) When this one gives me FALSE: is.na(as.POSIXlt(x = "03/09/2013 2:00", format = "%m/%d/%Y %H:%M")) What is it about…
1
vote
2 answers

Sapply Change the Format of my POSIXlt Date Variable

I am using POSIXlt to keep the dates. What I want to do is to change month days of each date variable as follows, but it gives an error. (Below, d is a list of dates.) > d [1] "2012-02-01 UTC" > a = sapply(d, function(x) { x$mday=14;}) Warning…
ibilgen
  • 460
  • 1
  • 7
  • 15
1
vote
0 answers

How to use a custom created POSIXlt Date class in colClasses argument when importing with fread in R?

I am trying to import date fields which are formatted as a character, into a POSIXlt class while importing the data itself. Instead of importing the date as character and converting to POSIXlt later, I want to do this in one step, since my data is…
Selva
  • 2,045
  • 1
  • 23
  • 18
1
vote
0 answers

How to select f POSIXlt data that falls into a certain timeframe?

I try to analyze some data imported from a .csv spreadsheet. To analyze the data I need to restrict my sample to a certain timeframe (from d.m.Y H:M:S to d.m.Y H:M:S). The time data is in format POSIXlt (converted from character as original input).…
Ronja
  • 21
  • 5
1
vote
3 answers

Counting POSIXlt times by day

I have a chunk of POSIXlt times in a data frame, and I'm trying to see how many occurrences of these observances (in this case, bike rides) I have per day. What's the best way to do that? The dates look like this: > rides$start.fmtd[1:25] [1]…
Roger Filmyer
  • 676
  • 1
  • 8
  • 24
1
vote
4 answers

Date manipulations using as.POSIXlt

I am trying to locate the nearest Sunday to today. I define today as: dt <- as.Date("2014-06-04") I can find the last Sunday by following: dt - as.POSIXlt(dt)$wday [1] "2014-06-01" I can find the next Sunday by following: dt +…
Shambho
  • 3,250
  • 1
  • 24
  • 37
1
vote
2 answers

Integer to POSIXlt

I'm starting to get a handle on how base R handles dates/times, but still have some uncertainty. Using the following data set (exert from meteorological data), I was able to convert to POSIXct and POSIXlt using the as.character() function. The…
vitale232
  • 615
  • 1
  • 11
  • 21
0
votes
0 answers

Error in as.POSIXlt.character(x, tz = tz(x)) : character string is not in a standard unambiguous format, what am I doing wrong?

I am working on a big satellite fix dataset. It's the same I used last year with different data, but at some point it stopped working properly showing me this error message: Error in as.POSIXlt.character(x, tz = tz(x)) : character string is not in a…
Devon
  • 17
  • 3
0
votes
1 answer

Issue with converting a date-time string with timezone offset to local time in R

I'm facing difficulties converting a date-time string with a timezone offset to local time in R. The date-time string I have is in the following format: "2021-01-05T09:00:00+01:00". I want to convert it to the local time in the timezone specified by…
Vincent Guyader
  • 2,927
  • 1
  • 26
  • 43
0
votes
0 answers

Error using POSIXlt in R: Character string is not in a standard unambiguous format

I am attempting the run the following line of code in R: as.POSIXlt(c("28/7/2022 17:56:20", "28/3/2021 1:10:41 PM"), tryFormats = c("%d/%m/%Y %I:%M:%OS %p", "%d/%m/%Y %H:%M:%OS"),…
0
votes
0 answers

as.POSIXlt plotting weekdays in one console but not another--locale matching issues

Background: I am trying to paste a date and a time column from a dataframe and run it through as.POSIXlt to create a datetime, which, when plotted, will show the day of the week on the x axis instead of Feb 1st 00:00:00, etc. I am making a script to…
kswp
  • 35
  • 3
0
votes
1 answer

How to translate POSIXt literals to SQL datetime literals

I want to use an R POSIXt constant in MS SQL relying as much as I can on dbplyr's automatic translation. However, it seems to get messed up: library(dbplyr) dat <- lubridate::ymd_hms("2022-11-12 00:01:25") ## class(dat) ## [1] "POSIXct" "POSIXt"…
thothal
  • 16,690
  • 3
  • 36
  • 71
0
votes
1 answer

How to Convert Date Time With Fractional Seconds and Additional Character

I am struggling to get date/time values converted. The issue is that the time component contains fractional seconds, and there are additional characters in the string that should be filtered out. The format is of the current data/time variable…
CardCape
  • 3
  • 3