简体   繁体   English

日期格式随DT和闪亮而变化

[英]date format change with DT and shiny

my problem is when i use datatable on my computer and on the server formatDate is changing i know i'm using method = 'toLocaleDateString' maybe it's not the good method 我的问题是当我在我的计算机上使用datatable并且在服务器上formatDate正在改变我知道我正在使用method = 'toLocaleDateString'也许这不是好方法

on my computer it give me the format i want : 在我的电脑上它给我我想要的格式:

1 février 2000 

21 mars 2000

on shiny it give me : 闪亮它给我:

01/02/2000

21/03/2000

local computer and server have Sys.timezone() 本地计算机和服务器有Sys.timezone()

[1] "Europe/Paris"

im trying to do it like this 我想这样做

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

Thank you 谢谢

With the development version of DT (>= 0.2.2) on Github, you can pass additional parameters to the date conversion method, eg 使用Github上的DT (> = 0.2.2)的开发版本 ,您可以将其他参数传递给日期转换方法,例如

datatable(a) %>%
  formatDate(1, method = 'toLocaleDateString', params = list('fr-FR'))

Or more parameters: 或更多参数:

datatable(a) %>% formatDate(
  1, method = 'toLocaleDateString',
  params = list('fr-FR',  list(year = 'numeric', month = 'long', day = 'numeric'))
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM