system.date.get*
This feature is new in Ignition version 7.8.1
Some of these functions are new in 7.8.1: getMillis, getSecond, getMinute, getHour12, getHour24, getDayOfWeek, getDayOfYear, getMonth, getQuarter, getYear
This function is a set of functions that include:
Function |
Description |
system.date.getMillis |
Extracts the milliseconds from a date, ranging from 0-999. |
system.date.getSecond |
Extracts the second from a date, ranging from 0-59. |
system.date.getMinute |
Extracts the minutes from a date, ranging from 0-59. |
system.date.getHour12 |
Extracts the hour from a date. Uses a 12 hour clock, so noon and midnight are returned as 0. |
system.date.getHour24 |
Extracts the hour from a date. Uses a 24 hour clock, so midnight is zero. |
system.date.getDayOfWeek |
Extracts the day of the week from a date. Sunday is day 1, Saturday is day 7. |
system.date.getDayOfMonth |
Extracts the day of the month from a date. The first day of the month is day 1. |
system.date.getDayOfYear |
Extracts the day of the year from a date. The first day of the year is day 1. |
system.date.getMonth |
Extracts the month from a date, where January is month 0. |
system.date.getQuarter |
Extracts the quarter from a date, ranging from 1-4. |
system.date.getYear |
Extracts the year from a date. |
system.date.getAMorPM |
Returns a 0 if the time is before noon, and a 1 if the time is after noon. |
system.date.get* ( date )
-
Parameters
Date date - The date to use.
-
Returns
Int - An integer that is representative of the extracted value.
-
Scope
All
#This example would grab the current time, and print the current month.
date
=
system.date.now()
print
system.date.getMonth(date)
#This would print the current month.
#This example would create a date object, and print out the quarter of that date.
date
=
system.date.getDate(
2017
,
3
,
15
)
#This would print "Mon April 15 00:00:00 PDT 2016"
print
system.date.getQuarter(date)
#This will print 2
#This example can be placed on the action performed event of a button.
#It will then grab the day of the week of the calendar component,
#and enter the value returned into a numeric text field.
date
=
event.source.parent.getComponent(
'Calendar'
).date
event.source.parent.getComponent(
'Numeric Text Field'
).intValue
=
system.date.getDayOfWeek(date)