time_ampmto24 - Lasso 8 custom tag converts a time with an AM/PM designation to 24-hour time

The project time_ampmto24 and its source files are hosted on GitHub.

Description

[time_ampmto24] converts a time with an AM/PM designation to 24-hour time. This tag accepts a time formatted as hh:mm AM|PM, and converts the time to hh:mm:ss 24-hour time format. This makes it easy to write the value to a database.

Programmers needlessly make it awkward to enter times into forms, especially when the time is broken into three select menus (hours, minutes, am/pm). Some programmers are lazy and trust users to enter a time in a "correct" format, but that leads to user errors. To mitigate the user interface issue, I use the jQuery plugin, Time Entry.

Demo

Demo.

Usage

1
2
3
<p>[time_ampmto24('07:00 AM')]</p>
<p>[time_ampmto24('07:00 PM')]</p>
<p>[time_ampmto24('07:00PM')]</p>
1
2
3
4
=>
07:00:00
19:00:00
Value is not in the proper time format of "hh:mm AP".

Installation

Instructions for installing time_ampmto24 are in the demo file time_ampmto24_demo/index.lasso.

Did you like this article? Please send me a Gratipay, as little as 25¢ per week!

Updates, suggestions and comments regarding this article may be sent to Steve Piercy, [email protected] or comment using Disqus.


Written by Steve Piercy in Lasso on Tue, Nov 27, 2012.
Last modified: Tue, Jun 3, 2014
Tags: time_ampmto24, Lasso, time

Comments

comments powered by Disqus