Skip to end of metadata
Go to start of metadata

This feature is new in Ignition version 7.9.1
Click here to check out the other new features
This function is used in Python Scripting.

Description

Attempts to parse a string and create a Date. Causes ParseException if the date dateString parameter is in an unrecognized format.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.date.parse(dateString, formatString, locale)

  • Parameters

String dateString - The string to parse into a date.

String formatString - Format string used by the parser. Default is "yyyy-MM-dd HH:mm:ss" [optional]

Object locale - Locale used for parsing. Can be the locale name such as 'fr', or the Java Locale such as 'Locale.French'. Default is 'Locale.English'. Click here for a list of supported locales and and values. [optional]

  • Returns

Date - The parsed date.

  • Scope

All

Code Examples
Code Snippet
# This example will return a date object set to the given date and time, May 28th, 1992 at 4:22am. 
print system.date.parse('May 28, 1992 4:22', 'MMMM dd, yyyy hh:mm')
Code Example - Using the Locale Parameter
# This example demonstrates the locale parameter to parse a French date
print system.date.parse("juillet 15, 2015 10:32:15", "MMMM dd, yyyy hh:mm:ss", "fr")
 
# If using the Java Locale, then you must import from the Locale class. The following example parses a German date.  
from java.util import Locale
print system.date.parse('21-Februar-2017 04:22:00', 'dd-MMMM-yyyy HH:mm:ss', Locale.GERMAN)
  • No labels