【发布时间】:2016-12-16 22:36:30
【问题描述】:
我的问题是当我在我的计算机和服务器上使用数据表时,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
谢谢
【问题讨论】:
-
toDateString可能会给你你想要的,除了星期几被添加到输出中;这在很大程度上取决于您的网络浏览器——不同的网络浏览器(和语言设置)可能会给您不同的输出。 -
toDateString给我英文格式Tue Feb 01 2000有没有办法在没有toLocaleDateString或类似date.toLocaleDateString('fr-FR')的developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… 的情况下强制使用法语格式 -
好主意。在 DT 的开发版中实现。