Store PLCnext CommunityPLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. Rob H
  2. PLCnext Engineer
  3. Tuesday, 07 April 2020

I am struggling to capture the current time in the local timezone. The controller is synced with a NTP server. I set the timezone to US Eastern and the $ date command returns the correct time in the correct timezone. I first tried using the PBCL_DateTimeGetString FB from the PLCnextBase library. It returns the correct UTC time. I tried creating a C# FB that used DateTime.UtcNow.ToLocalTime() but that still returned UTC time. It was suggested in this post to create C++ FB, but unfortunately I am unfamiliar with C++ development. Also, I have tested this on 2019.9 & 2020.0 with the same results. Any suggestions?

Thanks, 

Rob

Automation Engineer - Grand Rapids, MI, USA

Accepted Answer
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Rob,

A short update.

It is possible to get the local time using the "RTC" system variable in PLCnext Engineer. This variable has been introduced in a recent version of PLCnext Engineer, and wasn't available at the time of the earlier post you linked.

I will find out the answer to the DateTime.Now question and post it here, in case you are interested, and for future reference.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

  1. more than a month ago
  2. PLCnext Engineer
  3. # Permalink
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Rob, I'm sure you've tried it, but out of interest, what does DateTime.Now() give you?

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

  1. more than a month ago
  2. PLCnext Engineer
  3. # 1
Rob H Accepted Answer Pending Moderation
0
Votes
Undo

Hi Rob, I'm sure you've tried it, but out of interest, what does DateTime.Now() give you?

~ Martin.

DateTime.Now also returns UTC time. 

Automation Engineer - Grand Rapids, MI, USA

  1. more than a month ago
  2. PLCnext Engineer
  3. # 2
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Rob,

I have reproduced the problem you are seeing with the DateTime.Now function. This seems like a bug to me, but I will check this with the experts here.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

  1. more than a month ago
  2. PLCnext Engineer
  3. # 3
Rob H Accepted Answer Pending Moderation
0
Votes
Undo

Martin, 

Go to know about the RTC clock. That will solve my immediate problem. 

I also contacted the PLCnextBase developers. They mentioned a new release with FB's for UTC to Local Time and more. That will be ideal. 

Thanks for the quick repsonse, 

Rob 

Automation Engineer - Grand Rapids, MI, USA

  1. more than a month ago
  2. PLCnext Engineer
  3. # 4
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

For others interested in this issue, it has now been confirmed that the problem with DateTime values described in this thread is a bug in the firmware (as at version 2020.3.1), and will be fixed in a future release.

Sorry for the inconvenience.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

  1. more than a month ago
  2. PLCnext Engineer
  3. # 5
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

In the interests of closure:

This issue has been fixed in FW 2020.6.1. From the change notes:

From this version on, the block "RTC_S" returns the local time, provided a time zone with root rights has been set before. In previous versions, the UTC time was always returned.

This solution is provided by a bug-fix that also fixes the DateTime.Now issue discussed in this thread.

~ Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support

  1. more than a month ago
  2. PLCnext Engineer
  3. # 6
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.