Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep time zone information when converting POSIX object to string [duplicate]

Tags:

datetime

posix

r

I'm trying to convert a POSIX object to a string in R by using

as.character(Sys.time()) which returns "2021-09-28 08:38:13"

However, if I just run Sys.time() I get "2021-09-28 08:38:13 CEST".

How do I get the time zone information to be converted to the string, too?

like image 558
smoff Avatar asked Oct 27 '25 19:10

smoff


1 Answers

use option usetz = TRUE

as.character(Sys.time(), usetz = TRUE)
like image 173
Park Avatar answered Oct 29 '25 07:10

Park



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!