R functions for DateTimes in any time zone

I often find myself seeking a concise solution to check if I am running artificial intelligence stock trading algorithms at the right time for various exchanges around the world. Most of the users of our analyses want to see an analysis in their specific local time zone, so our scheduling servers and programs often have various checks, such as is it 3:59 PM in New York or 11:29 AM in Tokyo?

Here are two simple functions, to_tz() and now_tz(), with no package dependencies beyond Base R to address this specific area.

What time is it in New York?
now_tz(tz = “America/New_York”)
# “2016-12-29 19:02:14.84 EST”

How about Tokyo time for this after-hours New York trade at 2016-12-29 19:02:14.85 EST?
to_tz(tz_to = “Asia/Tokyo”,
date_time = “2016-12-29 19:02:14.85”,
tz_from = “America/New_York”

# “2016-12-30 09:02:14.83 JST”

 Subscribe to our newsletter

     Join the thousands who benefit from our
     newsletter, we promise to:
        + Send you valuable, exclusive content,
        + Never share your info, and
        + Offer you a simple way to unsubscribe.