Extract the weekday, month or quarter, or the Julian time (days since some origin). These are generic functions: the methods for the internal date-time classes are documented here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
weekdays(x, abbreviate) ## S3 method for class 'POSIXt' weekdays(x, abbreviate = FALSE) ## S3 method for class 'Date' weekdays(x, abbreviate = FALSE) months(x, abbreviate) ## S3 method for class 'POSIXt' months(x, abbreviate = FALSE) ## S3 method for class 'Date' months(x, abbreviate = FALSE) quarters(x, abbreviate) ## S3 method for class 'POSIXt' quarters(x, ...) ## S3 method for class 'Date' quarters(x, ...) julian(x, ...) ## S3 method for class 'POSIXt' julian(x, origin = as.POSIXct("1970-01-01", tz = "GMT"), ...) ## S3 method for class 'Date' julian(x, origin = as.Date("1970-01-01"), ...)
an object inheriting from class
logical vector (possibly recycled). Should the names be abbreviated?
an length-one object inheriting from class
arguments for other methods.
months return a character
vector of names in the locale in use.
quarters returns a character vector of
julian returns the number of days (possibly fractional)
since the origin, with the origin as a
All time calculations in R are done ignoring leap-seconds.
Other components such as the day of the month or the year are
very easy to compute: just use
as.POSIXlt and extract
the relevant component. Alternatively (especially if the components
are desired as character strings), use
1 2 3 4 5 6 7 8 9 10 11
weekdays(.leap.seconds) months(.leap.seconds) quarters(.leap.seconds) ## Julian Day Number (JDN, https://en.wikipedia.org/wiki/Julian_day) ## is the number of days since noon UTC on the first day of 4317 BC. ## in the proleptic Julian calendar. To more recently, in ## 'Terrestrial Time' which differs from UTC by a few seconds ## See https://en.wikipedia.org/wiki/Terrestrial_Time julian(Sys.Date(), -2440588) # from a day floor(as.numeric(julian(Sys.time())) + 2440587.5) # from a date-time
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.