문제

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