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
2
votes
1 answer

Calculate & add column length_of_time from date column in R

I am trying to create a new calculated field, length_of_time. I have a column final_date with dates: 2/10/2016 4/4/2016 5/8/2016 10/1/2016 and I am trying to calculate a new field showing length of time between 10/23/2016 and final_date. I…
James Steele
  • 645
  • 1
  • 6
  • 22
2
votes
2 answers

Adjust data time zone in R

For some reason I can't adjust the time zone by as.POSIXlt. time <- "Wed Jun 22 01:53:56 +0000 2016" t <- strptime(time, format = '%a %b %d %H:%M:%S %z %Y') t [1] "2016-06-21 21:53:56" Can't change the time zone as.POSIXlt(t, "EST") [1] "2016-06-21…
Yan Chen
  • 31
  • 2
2
votes
1 answer

R Change date YY-MM-DD hh:mm to time since origin (Days.Seconds)

I have a date input like this (currently as character class): input=c("2013-05-08 11:20:10", "2013-05-08 11:21:09") And want to have an output like this: output=c(127.472338, 127.473032) Which is the time since origin (2013-01-01 00:00:00) in days…
Anne
  • 377
  • 2
  • 4
  • 16
2
votes
1 answer

Converting combined Day/Time decimal format to POSIX

I have a data set that I believe is given in 20 minute increments. The year and month columns are given in a standard decimal value. But the the Day and Hour/Min/Sec data are given as a combined decimal (First digit is "Day", following decimal…
Vinterwoo
  • 3,843
  • 6
  • 36
  • 55
2
votes
0 answers

What is the origin argument in as.POSIXlt.numeric that I would need to use for this example?

For work I need to find if a vector of dates falls on the week after Christmas. To do that, I thought the smartest first step would be to find the first day that falls in that period across the years I'm interested in. I've been able to use the…
cylondude
  • 1,816
  • 1
  • 22
  • 55
2
votes
1 answer

Convert column to date-format with a space and milliseconds

I've been trying to figure this out for a few days now, and seem to be having difficulties doing a simple date column conversion in R. I need to format the date and time before I am able to use the to.period command. I would like to format the…
user3773444
  • 333
  • 3
  • 12
1
vote
0 answers

How should I use the as.POSIXlt function within a data.table?

In R, I'm trying to convert a POSIXct variable to a POSIXlt variable within a data table. For some reason this fails, though other type-conversion functions work. library(data.table) # make a sequence of dates start_date <-…
plevy
  • 11
  • 2
1
vote
0 answers

Wrapping POSIXlt in a vector changes the time zone

I would like to create a data frame in which I have a column of POSIXlt data. In the following way, unfortunately the time zone is lost and the time is shifted by one hour (I'm in Switzerland) df <- data.frame( DateTime=c( …
Davide
  • 1,931
  • 2
  • 19
  • 39
1
vote
1 answer

generation of time series without daylight savings - r

I'm trying to generate a time series from 2000-01-01 00:00:00 to 2020-12-31 23:00:00 (hourly timestep), without taking into account daylight savings. Other posts suggest using GMT or UTC when generating it as POSIX. So this is what I tried: ## …
1
vote
0 answers

Error : Column `Fecha` can't be converted from POSIXct, POSIXt to character ( in R)

I have 13 xlsx files in a folder that have the same columns. So i'd like to open them in a row in R and append them together. Two of the columns (Fecha 1, Fecha 2) contain dates. Fecha 1 is in format yyyy-mm-dd and fecha 2 in the format…
katdataecon
  • 185
  • 8
1
vote
2 answers

R: Create Function to Add Water Year Column

I am attempting to add a column to my dataframe that lists the hydrological water year for each sample. A water year is defined as October 1st of the previous calendar year through September 31st. For example, WY 2014 starts 10/1/2013 and ends…
MicaelaB
  • 33
  • 3
1
vote
1 answer

R code to change date for an entire column

I am trying to edit a column of datetime values in R that are in POSIXlt format. I would like to add or subtract each row in this column by a scalar value of hours to change timezones. so far my code looks like: df$Time_LMT <-…
1
vote
1 answer

Selecting and grouping similar dates from vectors of dates

I have three vectors of dates in POSIX format that correspond with data collection times from three large datasets. Each of these vectors is of a different length and have similar (but not identical) dates. I would like to: group these dates into…
1
vote
1 answer

Problem to convert string with month abbreviation to POSIXlt

I tried to convert Excel date character to date-time class using POSIXlt. This is an example of my data: "01:56:00 06-Apr-2017". For the format, I used the character string giving a date-time format as used by strptime. I tried as.POSIXlt(new_dtime,…
Majo
  • 13
  • 2
1
vote
1 answer

Merge data frames by date generating NA

I'm learning R and currently trying to fill in a data frame with missing dates and NA values. Data sample: Date <- c("23-01-19", "24-01-19", "25-01-19", "30-01-19", "31-01-19" ) Open <- c("69.849998", "69.440002", "69.540001", "70.32",…
ToniR
  • 37
  • 5
1 2
3
10 11