How to write regular expression for Time

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
shahzadzaveri

How to write regular expression for Time

Post by shahzadzaveri »

I need to add one customer field as From Time to To Time and want that user should input time only in the following format:
HH:MM:SS i.e. 18:20:30 and 18:30:30

How it can be done? and is it possible that in the next custom field, it automatically calculate the difference of From Time to To Time i.e. 10 Minutes.

Awaiting your reply.
dregad
Developer
Posts: 94
Joined: 26 Jul 2010, 14:24

Re: How to write regular expression for Time

Post by dregad »

We don't have "time" type custom fields. I suggest instead to use text field with a regular expression to validate the user's input, maybe something like (not tested)

Code: Select all

[0-2][0-9]:[0-5][0-9]:[0-5][0-9]
With regards to the calculation, I can't think of a way to easily do it out of the box. Maybe you can write a custom plugin.
shahzadzaveri

Re: How to write regular expression for Time

Post by shahzadzaveri »

Thanks dregad ..... so nice of you ... it has resolved my issue ...
Post Reply