Search code examples
phpepoch

epoch time with decimals is wrong


A third party API is outputting: "1373762187.198" as a valid date time.

When passed through PHPs date function, I get todays date even though I know the object its attached to is over a week old.

Any ideas how todo a correct conversation?


Solution

  • Just strip the decimals away with an integer cast and then pass it to date (or do you need the milliseconds?)

    date("...", (int)$date);