Hi there everyone,

I'm working on a latest forum posts block and am trying to convert a stored time like "1276027275" into a readable format like "12:00pm June 8". I'm reading the php manual on microtime, but I'm having a problem finding the proper method of converting/formatting it.

any help would be greatly appreciated.

thanks,
json

    Are you truly using microtime(), or just time()? If using microtime(), are you getting it as a float (with the optional argument) or as a string (in the format "msec sec")?

    PS: From your example value, that looks like it's just seconds to me, in which case you could easily output it via [man]date/man:

    echo date('Y-m-d H:i:s', $timeInSeconds);
    

      You would use time() or date() functions for that sort of application. Microtime measures down to milliseconds which is just primarily used to find the speed of events that occur in microseconds.

      date("Y-m-d H:i:s", time());
      

      date() formats the time (if your importing a time from a db you would use strtotime($date) instead of time()).

        Write a Reply...