• 2918 views
  • 0 comments
  • loading...

Date and time validators

IS_DATETIME validator checks that a field value contains a valid datetime in the specified format. It is good practice to specify the format using the translation operator, in order to support different formats in different locales.

Check format argument for symbols which can be used for the format string .


requires = IS_DATETIME(format=T('%Y-%m-%d %H:%M:%S'),

error_message='must be YYYY-MM-DD HH:MM:SS!')

Attributes / Arguments

It is good practice to specify the format using the translation operator, in order to support different formats in different locales.

requires = IS_DATETIME(format=T('%Y-%m-%d %H:%M:%S'))

# % directives (this shows the symbol and an example string):
%Y  '1963'
%y  '63'
%d  '28'
%m  '08'
%b  'Aug'
%b  'August'
%H  '14'
%I  '02'
%p  'PM'
%M  '30'
%S  '59'

Displays an error message

requires = IS_DATETIME(format=T('%Y-%m-%d %H:%M:%S'),
                       error_message='must be YYYY-MM-DD HH:MM:SS!')


Examples

loading...

Sources / Reference

" Web2py Book"


Comments

loading...

Powered by
Web2py

Hosted on
www.pythonanywhere.com
(affiliated link)