Changes for page 2 Script
Last modified by Devin Chen on 2025/12/10 10:32
To version 2.1
edited by Devin Chen
on 2025/09/05 11:50
on 2025/09/05 11:50
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
-
Attachments (0 modified, 3 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. Wecon1 +XWiki.DevinChen - Content
-
... ... @@ -1,3 +1,6 @@ 1 += = 2 + 3 + 1 1 = **1 General Script Demo** = 2 2 3 3 == **1.1 Address Operation** == ... ... @@ -560,6 +560,58 @@ 560 560 end 561 561 {{/code}} 562 562 566 += **1.12 Get UTC timestamp and local timezone timestamp** = 567 + 568 +This demo shows how to obtain UTC standard time from the V-Box and get the local time based on the device's time zone. 569 + 570 +**Register configuration** 571 + 572 +[[image:1757043722849-910.png]] 573 + 574 +**Script configuration** 575 + 576 +(% style="text-align:center" %) 577 +[[image:1757043900216-610.png||height="412" width="439"]] 578 + 579 + 580 +**Script** 581 + 582 + 583 + 584 +{{code language="lua"}} 585 +function time.main() 586 + 587 + --Get Coordinated Universal Time 588 + local timestamp = os.time() 589 + local utcTimeTable = os.date("!*t", timestamp) 590 + local utcTimestamp = os.time(utcTimeTable) 591 + local formattedTime = os.date("%Y-%m-%d %H:%M:%S", utcTimestamp) 592 + 593 + print("UTC: " ..formattedTime) 594 + 595 + --Calculate the local time at the device's location 596 + local utc_7Timestamp = os.time(utcTimeTable) + 25200 -- Enter the corresponding number of seconds based on the time difference,used UTC+7 as an example.. 597 + local formattedTime1 = os.date("%Y-%m-%d %H:%M:%S", utc_7Timestamp) 598 + print("UTC+7: " .. formattedTime1) 599 + 600 + 601 + --Assign the decomposed timestamp to the specified register 602 + addr_setword("@UTC+7_Second",os.date("%S", utc_7Timestamp)) 603 + addr_setword("@UTC+7_Minute",os.date("%M", utc_7Timestamp)) 604 + addr_setword("@UTC+7_Hour",os.date("%H", utc_7Timestamp)) 605 + addr_setword("@UTC+7_Day",os.date("%d", utc_7Timestamp)) 606 + addr_setword("@UTC+7_Month",os.date("%m", utc_7Timestamp)) 607 + addr_setword("@UTC+7_Year",os.date("%Y", utc_7Timestamp)) 608 + print("--------------------------------------") 609 + 610 +end 611 +{{/code}} 612 + 613 +**Result** 614 + 615 +(% style="text-align:center" %) 616 +[[image:1757044137457-543.png||height="468" width="708"]] 617 + 563 563 = **2 Third part server** = 564 564 565 565 V-Box have two mode.One is for V-Net,User need to use WECON server to store data.We call this V-NET platform.
- 1757043722849-910.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.DevinChen - Size
-
... ... @@ -1,0 +1,1 @@ 1 +74.4 KB - Content
- 1757043900216-610.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.DevinChen - Size
-
... ... @@ -1,0 +1,1 @@ 1 +62.9 KB - Content
- 1757044137457-543.png
-
- Author
-
... ... @@ -1,0 +1,1 @@ 1 +XWiki.DevinChen - Size
-
... ... @@ -1,0 +1,1 @@ 1 +99.4 KB - Content