Code:
<?php int DMYToExcelSerialDate(int nDay, int nMonth, int nYear) { // Excel/Lotus 123 have a bug with 29-02-1900. 1900 is not a // leap year, but Excel/Lotus 123 think it is... if (nDay == 29 && nMonth == 02 && nYear==1900) return 60; // DMY to Modified Julian calculatie with an extra substraction of 2415019. long nSerialDate = int(( 1461 * ( nYear + 4800 + int(( nMonth - 14 ) / 12) ) ) / 4) + int(( 367 * ( nMonth - 2 - 12 * ( ( nMonth - 14 ) / 12 ) ) ) / 12) - int(( 3 * ( int(( nYear + 4900 + int(( nMonth - 14 ) / 12) ) / 100) ) ) / 4) + nDay - 2415019 - 32075; if (nSerialDate < 60) { // Because of the 29-02-1900 bug, any serial date // under 60 is one off... Compensate. nSerialDate--; } return (int)nSerialDate; } print (nSerialDate); ?>
Comment