Helper::convertMySQL2NHS PHP Method

convertMySQL2NHS() public static method

Strings that do not match MySQL date(time) format return $empty_string.
public static convertMySQL2NHS ( string $value, string $empty_string = '-' ) : string
$value string
$empty_string string
return string
    public static function convertMySQL2NHS($value, $empty_string = '-')
    {
        if (preg_match('/^\\d{4}-\\d{2}-\\d{2}/', $value) && $value != '0000-00-00 00:00:00' && $value != '0000-00-00') {
            return self::convertDate2NHS($value, $empty_string);
        } else {
            return $empty_string;
        }
    }

Usage Example

Example #1
0
    ?>
 column">
			<label for="<?php 
    echo CHtml::modelName($element) . '_' . $field . '_0';
    ?>
">
				<?php 
    echo CHtml::encode($element->getAttributeLabel($field));
    ?>
:
			</label>
		</div>
		<div class="large-<?php 
    echo $layoutColumns['field'];
    ?>
 column end">
<?php 
}
?>

	<?php 
$this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => $name, 'id' => CHtml::modelName($element) . '_' . $field . '_0', 'options' => array_merge($options, array('showAnim' => 'fold', 'dateFormat' => Helper::NHS_DATE_FORMAT_JS)), 'value' => preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value) ? Helper::convertMySQL2NHS($value) : $value, 'htmlOptions' => $htmlOptions));
?>

<?php 
if (!@$htmlOptions['nowrapper']) {
    ?>
		</div>
	</div>
<?php 
}
All Usage Examples Of Helper::convertMySQL2NHS