Accessing current system date and time

Byron S
  • Byron S

    Byron S - 2010-12-07

    Does anyone know of a way to retrieve the current date and time from the operating system?  I'm using CLIPS 6.3 on a Windows platform.  

  • Gary Riley

    Gary Riley - 2011-01-01

    Here's one way to retrieve the values as strings:

    (deffunction system-string (?arg)
       (bind ?arg (str-cat ?arg " > temp.txt"))
       (system ?arg)
       (open "temp.txt" temp "r")
       (bind ?rv (readline temp))
       (close temp)
    CLIPS> (system-string "date /t")
    "Sat 01/01/2011 "
    CLIPS> (system-string "time /t")
    "05:34 PM"

  • Anonymous - 2012-01-20

    Hi, i would like to know how to get only the year if it would be possible.

    Thanks a lot

  • Gary Riley

    Gary Riley - 2012-04-13

    Once you've got the string with the date in it, just use the string manipulation functions:

    CLIPS> (sub-string 11 14 "Sat 01/01/2011 ")


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks