11 - 392 11 - 392
MELSEC-Q
11 INSTRUCTIONS AND FUNCTIONS
TIME$
Function
TIME$
• Sets the time of the PLC CPU's clock.
• Reads the time of the PLC CPU's clock.
TIME$="<hour>:<minute>:<second>"
TIME$
Syntax
Hour
• • • •
Specify the character string that indicates the hour in
the range from "00" to "23."
Minute
• • • •
Specify the character string that indicates the minute
in the range from "00" to "59."
Second
• • • •
Specify the character string that indicates the second
in the range from "00" to "59."
Examples
TIME$="11:57:30"
• • • •
Sets the PLC CPU's clock to 11 o'clock, 57 minutes,
30 seconds.
A$=TIME$
• • • •
Reads the time from the PLC CPU's clock and
assigns it to A$.
Description
• The TIME$ function is used to set the time of the PLC CPU's clock and read the time of the
clock.
• Set the time using the following format:
TIME$="hour:minute:second"
1) Use colons (" : ") to separate hours, minutes, and seconds.
2) The hours are specified in 24-hour format, from 0 to 23.
3) If either of the specifications is 0 to 9, add a leading 0 to make it 00 to 09.
4) All three values for the hours, minutes, and seconds must be specified, without
omission.
• The time value is read in the same format as when the time is set.
• The TIME$ function is valid only for PLC CPUs with the clock function. The TIME$ function cannot
be executed for PLC CPUs without the clock function (i.e., A , A3H, A0J2(H)CPU).
• Store dummy data in a value used to read the date (year, month, date) as shown below before using
the DATE$ function.
If dummy data is not stored, an error occurs.
$=SPACE$(14)
$(n)=SPACE$(14)
Program Example
10 ' This program sets and reads the time
30 A$="13:23:01"
:
' Sets the time
40 TIME$=A$
:
' Writes the time
60 B$=SPACE$(8)
:
' Stores dummy data
70 B$=TIME$
:
' Reads the time
80 PRINT "The time on the clock --->";B$
:
' Checks the time that was read
90 END
RUN
The time on the clock ---> 13:23:01
OK