RTC Timestamp | LabJack
 

RTC Timestamp

6 posts / 0 new
Last post
wil1277
wil1277's picture
RTC Timestamp

Is there a way to convert the RTC timestamp in LUA from UTC to Pacific Time?  My test requires a date and time during data log and this data is saved to a csv file.  The code below prints in UTC time.

local table = {} table[1] = 0 --year table[2] = 0 --month table[3] = 0 --day table[4] = 0 --hour table[5] = 0 --minute table[6] = 0 --second table, error = MB.R(61510, 0, 6) --read the RTC timestamp datestr = string.format("%04d/%02d/%02d %02d:%02d.%02d", table[1], table[2], table[3], table[4], table[5], table[6]) print(datestr) file:write(datestr, "\n")    

 

 

LabJack Support
labjack support's picture
In order to convert UTC time

In order to convert UTC time to Pacific Time you will need to either manually subtract the time difference between UTC and Pacific or you can configure the device's RTC with this difference already accounted for by writing to the RTC_SET_TIME_S register.  According to worldtimebuddy.com there is a 7 hour difference between Pacific Time and UTC.  The T-Series devices don't currently have a built-in function that does this for you.

wil1277
wil1277's picture
thank you.  I have another

thank you.  I have another question. 

There's a sample lua script in LabJack Kipling "Read RTC".  When I run the script, it is showing yesterday's date and not today's date. Do I need to configure something so it will show today's date?  Thanks.  
LabJack Support
labjack support's picture
The time can be updated using

The time can be updated using the RTC_SET_TIME_S register or by using internet timer servers (SNTP). More infomraiton is availble here: https://labjack.com/support/datasheets/t-series/rtc

wil1277
wil1277's picture
Can you show me the code on

Can you show me the code on how to use the RTC_SET_TIME_S to update the time.  Sorry, I'm new to labjack and I'm still learning how to use the lua language.  Thanks so much.

 

LabJack Support
labjack support's picture
If you are using Lua then we

If you are using Lua then we do not have a source from which to get the current time. Options are

*Use the button on the dashboard to set the T7's time to your computer's system time. Note that only the T7-Pro has a RTC, so the time on normal T7s will need to be reset every time the unit is powered on.

*Connect the T7 to an Ethernet netowrk with internet access and let SNTP update the timer.

Is it unusual for the RTC on a T7-Pro to be off by an entire day. The issue may simple be due to time-zone.