當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


R lubridate now 當前日期和時間

當前日期和時間

用法

now(tzone = "")

today(tzone = "")

參數

tzone

一個字符向量,指定您希望當前時間所在的時區。tzone 默認為您計算機的係統時區。您可以使用 now("UTC") 檢索通用協調時間 (UTC) 中的當前時間。

now - 作為 POSIXct 對象的當前日期時間

例子

now()
#> [1] "2023-02-14 11:55:06 UTC"
now("GMT")
#> [1] "2023-02-14 11:55:06 GMT"
now("")
#> [1] "2023-02-14 11:55:06 UTC"
now() == now() # would be TRUE if computer processed both at the same instant
#> [1] FALSE
now() < now() # TRUE
#> [1] TRUE
now() > now() # FALSE
#> [1] FALSE
today()
#> [1] "2023-02-14"
today("GMT")
#> [1] "2023-02-14"
today() == today("GMT") # not always true
#> [1] TRUE
today() < as.Date("2999-01-01") # TRUE  (so far)
#> [1] TRUE
源代碼:R/instants.r

相關用法


注:本文由純淨天空篩選整理自Hadley Wickham等大神的英文原創作品 The current day and time。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。