$str = (date('Y') >= 2000? 1 : 0) . date('ymd');
echo $str;
How can I display the current date in PHP in the CYYMMDD format?
-
03-10-2022 - |
Pregunta
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!
Solución
Otros consejos
Convert a full YYYYMMDD format into CYYMMDD format by subtracting 19000000:
For example:
<?php echo date('Ymd') - 19000000 ?>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow