easyappointments/src/application/helpers/data_validation_helper.php

28 lines
954 B
PHP
Raw Normal View History

<?php defined('BASEPATH') OR exit('No direct script access allowed');
2015-10-18 20:48:39 +03:00
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
2017-01-31 09:35:34 +03:00
* @copyright Copyright (c) 2013 - 2017, Alex Tselegidis
2015-10-18 20:48:39 +03:00
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.0.0
* ---------------------------------------------------------------------------- */
/**
* Check if a string date is valid for insertion or update
* to the database.
*
* @param string $datetime The given date.
* @return bool Returns the validation result.
*
* @link http://stackoverflow.com/a/8105844/1718162 [SOURCE]
*/
function validate_mysql_datetime($datetime)
{
2015-10-18 20:48:39 +03:00
$dt = DateTime::createFromFormat('Y-m-d H:i:s', $datetime);
return ($dt) ? TRUE : FALSE;
}