Sign in to follow this  
Followers 0
skyfox

NX1P2 Date to US format?

4 posts in this topic

NX1P2 seems to display date in "yyyy-mm-dd" format. Short of doing string manipulation, anyway to get current time in "mm-dd-yyyy" format?

Thanks.

 

 

Share this post


Link to post
Share on other sites

You can use the Function DtToDateStruct(In:=, DateStruct=>);

// =========================================================

VAR

s_dtCurrentTime : DATE_AND_TIME;

s_scCurrentTime : _sDT;

END_VAR;

// ----------------------------------------------------------------------------------------------------

s_dtCurrentTime := GetTime();

DtToDateStruct(In:= s_dtCurrentTime, DateStruct=> s_scCurrentTime);

// Access for each member of the DATE_AND_TIME, and the treatment of these members is best done separately

(*s_scCurrentTime.Year; [...].Month; [...].Day; [...].Hour; [...].Min; [...].Sec; [...].Nsec*)

// =========================================================

I hope I've helped you.

Share this post


Link to post
Share on other sites

Thank you.

I am currently doing something similar to that using a variable with a data type of "Date_AND_TIME". I was trying to avoid doing it this way and was looking to see if there was a way to do it in PLC's hardware configuration. This was for a high speed data logging application and didn't want to waste time composing the date time format at each log interval. 

Thanks again

Cheers.

 

Share this post


Link to post
Share on other sites
15 hours ago, skyfox said:

waste time composing the date time format at each log interval

Sysmac Date_and_Time is 64-bit integer nanoseconds from the Unix Epoch.  If you transfer using a tag set on Ethernet/IP, the other end can simply re-interpret the bytes to get the precise time.

(It isn't UTC, though, in contrast to AB's WallClock.  I recommend using UTC on all Omron PLCs' clocks.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0