日期格式随 DT 和闪亮变化
date format change with DT and shiny
我的问题是当我在我的计算机和服务器上使用数据表时 formatDate
正在改变
我知道我正在使用 method = 'toLocaleDateString'
也许这不是好方法
在我的电脑上它给了我我想要的格式:
1 février 2000
21 mars 2000
闪亮它给我:
01/02/2000
21/03/2000
本地电脑和服务器有Sys.timezone()
[1] "Europe/Paris"
我正在尝试这样做
a <-structure(list(timestamp = structure(c(949363200, 953596800,
961286400, 962582400, 965347200, 969667200),
class = c("POSIXct", "POSIXt"), tzone = "UTC"),
anoms = c(1, 1, 1, 1, 1, 2), syndrome = c("Acrosyndrome",
"Acrosyndrome", "Acrosyndrome", "Acrosyndrome", "Acrosyndrome",
"Acrosyndrome")), .Names = c("timestamp", "anoms", "syndrome"
), row.names = c(NA, 6L), class = "data.frame")
datatable(a) %>% formatDate( 1, method = 'toLocaleDateString')
a
谢谢
使用 DT (>= 0.2.2) on Github 的 development version,您可以将其他参数传递给日期转换方法,例如
datatable(a) %>%
formatDate(1, method = 'toLocaleDateString', params = list('fr-FR'))
或更多参数:
datatable(a) %>% formatDate(
1, method = 'toLocaleDateString',
params = list('fr-FR', list(year = 'numeric', month = 'long', day = 'numeric'))
)
我的问题是当我在我的计算机和服务器上使用数据表时 formatDate
正在改变
我知道我正在使用 method = 'toLocaleDateString'
也许这不是好方法
在我的电脑上它给了我我想要的格式:
1 février 2000
21 mars 2000
闪亮它给我:
01/02/2000
21/03/2000
本地电脑和服务器有Sys.timezone()
[1] "Europe/Paris"
我正在尝试这样做
a <-structure(list(timestamp = structure(c(949363200, 953596800,
961286400, 962582400, 965347200, 969667200),
class = c("POSIXct", "POSIXt"), tzone = "UTC"),
anoms = c(1, 1, 1, 1, 1, 2), syndrome = c("Acrosyndrome",
"Acrosyndrome", "Acrosyndrome", "Acrosyndrome", "Acrosyndrome",
"Acrosyndrome")), .Names = c("timestamp", "anoms", "syndrome"
), row.names = c(NA, 6L), class = "data.frame")
datatable(a) %>% formatDate( 1, method = 'toLocaleDateString')
a
谢谢
使用 DT (>= 0.2.2) on Github 的 development version,您可以将其他参数传递给日期转换方法,例如
datatable(a) %>%
formatDate(1, method = 'toLocaleDateString', params = list('fr-FR'))
或更多参数:
datatable(a) %>% formatDate(
1, method = 'toLocaleDateString',
params = list('fr-FR', list(year = 'numeric', month = 'long', day = 'numeric'))
)