Thanks for providing us some details.
When you apply built-in numbers formatting in code, the Date/Time values are converted in accordance with locale/regional settings of the system/environment when you open the output file into MS Excel there.
If you apply custom numbers formatting in code, then the DateTime value would be independent and does not change with locale/regional settings.
Keep the above points in mind. Also, I am not entirely certain about your issue, so if you still have confusion/problem, kindly do provide more details, sample code (runnable) and sample files (input (if any) and output file, etc.), we will check it soon. Also provide a file with your expected DateTime in the cell, you may manually create the file in MS Excel. This will help us really to evaluate your issue precisely and to consequently figure it out soon.
PS. please zip the Excel files prior attaching.