CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 PHP - Complete Validation of 24 hr time (cannot be 23:66)

Print topic Send  topic

Author Message
MichaelMcDonald

Posts: 640
Posted: 12/26/2014, 4:02 PM

In noticed that with date format dd/mm/yy H:nn that validation will accept times greater than 23:59

Not sure if I am missing a feature in CCS which will enforce upper limit of 23:59, so this is the answer:

$breakstart = CCFormatDate($recordtimesheetlineitem->breakstart->GetValue(), array("dd", "/", "mm", "/", "yy", " ", "H", ":", "nn"));

list($day, $month, $year, $hour, $minute) = split('[/ :]', $breakstart);
$breakstart = mktime($hour, $minute, 0, $month, $day, $year);

if(($hour > 23) or ($minute > 59)){
$recordtimesheetlineitem1->Errors->addError("Break Start Time format must be 24 hr.");
}

Due to varying numbers of days in calendar months I recommend allowing the CCS validation to handle day, month and year as it does this effectively.
_________________
Central Coast, NSW, Australia.

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.