Use the localtime() function.
There's an example on that page.