Search code examples
phpstring-formattingdatetime-formatphp4

Formatting date/time in php 4


I'm working (or learning) on server with old php4 installed and most of the conventional methods from php5 for date/time formatting doesn't work in php4.

I have time string in this format:

2003-07-23 10:15:00

Now whats the easiest way to get date separately in 23.7.2003 format and then time in 10:15 format?


Solution

  • Have you ever tried strtotime?

    print date('d.m.Y H:i', strtotime('2003-07-23 10:15:00'));
    

    Code running on PHP 4