Get UTC date time and convert to bytes using VisualLisp

Anonymous

Get UTC date time and convert to bytes using VisualLisp

Anonymous
Not applicable

Hi, 

 

I'm new to AutoLisp. I am wondering if there is a way to get DateTime in UTC. 
I know we can use CDate and Date but it only return PC date.

And also how to convert Date Time to bytes?

 

Thank you so much 

0 Likes
Reply
1,092 Views
3 Replies
Replies (3)

hencoop
Advisor
Advisor

I'm not sure of exactly what you are looking for but DOSLIB from Robert McNeel & Associates has some date tools (and lots of other good tools) that could help you.

 

DOS_CDATE.jpg

 

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024

Anonymous
Not applicable

I need to get current UTC datetime with autolisp.

 

I tried common lisp comand use (get-universal-time) . It will return 

 

                        ; error: no function definition: GET-UNIVERSAL-TIME

 

Now my code is 

 

(defun c:testing
  (setq time (rtos (getvar "CDATE")))
  (princ)
  (princ time)  
  (princ)
)

 

It returns 

 

20170329.0941  (current PC datetime)

 

 

I need to return 

20170329.0141  (current UTC datetime)

 

 

 

dbroad
Mentor
Mentor

If you're trying to get a time 8 hours earlier in a string similar to CDATE, then this should work:

(menucmd "M=$(edtime,$(-,$(getvar,date),0.3333333333),YYYYMODD\".\"HHMMSSMSEC)")
Architect, Registered NC, VA, SC, & GA.