I have the following code; $date = date("d/m/y G:i","20060526154458"); echo $date; which when I print it gives the date as 19/01/38 3:14 I'm obviously doing something daft. Any ideas?
Yeah Steve, would be handy to know what you;re actually trying to accomplish because that code is just fine... You're getting there what you are asking for.
is this what you are trying to do? $date = date("d/m/y G:i",mktime(15,44,58,05,26,2006)); echo $date; Code (markup):
Yes Weirfire's code is doing what it's supposed to but I believe what he's referring to is the fact that the date it's outputting isn't what he's expecting. The problem is his "timestamp" is not a valid one (unix timestamps only have 10 digits), so the date is wrong since the timestamp is out of range.
Try this: $date = date("d/m/y G:i", strtotime("20060526154458")); echo $date; PHP: Returns: 26/05/06 15:44
Thanks Young Twig. Thats exactly what I was looking for. Sorry guys... I should have specified what output I was trying to achieve.
If you're getting that number from DB, you can just do SELECT UNIX_TIMESTAMP(datecolumn) AS datecolumn and don't have to do the strtotime.