Question

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!

Was it helpful?

Solution

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

OTHER TIPS

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

For example:

<?php echo date('Ymd') - 19000000 ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top