I am trying to find a way to get the current date in to the CYYMMDD format so that I can do an SQL call to our AS400. Does anyone have an easy way of doing this in PHP or will I have to create an RPG program to do it?

Century - Year - Month - Date

Example:

1/27/2014 would convert to 1140127 and 1/26/2014 would convert to 1140126

Thanks!

有帮助吗?

解决方案

$str = (date('Y') >= 2000? 1 : 0) . date('ymd');
echo $str;

其他提示

Convert a full YYYYMMDD format into CYYMMDD format by subtracting 19000000:

For example:

<?php echo date('Ymd') - 19000000 ?>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top