日期格式随着DT和闪亮而变化 [英] date format change with DT and shiny

查看:75
本文介绍了日期格式随着DT和闪亮而变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是当我在计算机和服务器上使用数据表 formatDate 更改
i时知道我正在使用方法= 'toLocaleDateString'也许不是一个好方法

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

在我的计算机上,它给了我我想要的格式:

on my computer it give me the format i want :

1 février 2000 

21 mars 2000

关于闪亮它给我:

01/02/2000

21/03/2000

本地计算机和服务器具有 Sys.timezone ()

local computer and server have 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)在Github上,您可以将其他参数传递给日期转换方法,例如

With the development version of DT (>= 0.2.2) on Github, you can pass additional parameters to the date conversion method, e.g.

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'))
)

这篇关于日期格式随着DT和闪亮而变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆