5

I Have some values which are milliseconds since epoch i.e. microtime(true) in my MySQL database these are got out as strings I need to convert them over to a standard PHP date()

$updated = 1349697975.9381;
$nUpdated = date($updated, "l jS F \@\ g:i a");

This is returning a blank string, anyone help?

2 Answers 2

10

It should be date ( string $format [, int $timestamp = time() ] )

You got the position wrong

   $nUpdated = date("l jS F \@ g:i a",$updated);

Output

Monday 8th October @ 2:06 pm
2
  • 2
    I don't understand the second backslash, what does it escape? :) +1 Commented Oct 8, 2012 at 14:46
  • Mihai Iorga was taling about `\@` @Justin Erswell
    – Baba
    Commented Oct 8, 2012 at 14:50
0

You have the arguments to date() backwards (the timestamp is the second parameter).

Try updating to:

$nUpdated = date("l jS F \@ g:i a", $updated);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.