Skip to content

Commit

Permalink
Populate Date: Improved support for 24-hour Time fields
Browse files Browse the repository at this point in the history
  • Loading branch information
claygriffiths committed Mar 9, 2022
1 parent 5cc028a commit 981ae57
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gravity-forms/gw-populate-date.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Provides the ability to populate a Date field with a modified date based on the current date or a user-submitted date.
*
* @version 2.5.1
* @version 2.5.2
* @author David Smith <[email protected]>
* @license GPL-2.0+
* @link http://gravitywiz.com/populate-dates-gravity-form-fields/
Expand Down Expand Up @@ -1588,7 +1588,13 @@ function processTzCorrection(tzOffset, oldValue) {
missingData = ! hour || ! min,
datetime = missingData ? false : new Date();

datetime.setHours( parseInt( hour ) + ( ampm.toLowerCase() === 'pm' ? 12 : 0 ) );

if ( $inputs.eq( 2 ).length ) {
datetime.setHours( parseInt( hour ) + ( ampm.toLowerCase() === 'pm' ? 12 : 0 ) );
} else {
datetime.setHours( parseInt( hour ) );
}

datetime.setMinutes( min );

timestamp = datetime.getTime();
Expand Down

0 comments on commit 981ae57

Please sign in to comment.