Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Converting UNIX time (https://www.warriorforum.com/programming/269307-converting-unix-time.html)

Big Squid 5th October 2010 09:53 PM

Converting UNIX time
 
My brain has melted and is oozing out my ears!

I need help with a code that will convert UNIX timestamps on the fly. That is, I'm writing to php to use with an API. The data will be generated using a FOREACH loop.

Again, I only have access to the data using API.

Here's the code:

Code:

      foreach ($resp['body']['members'] as $members) {
            echo '<p>Members: <br />'.
                'Join Date: '. $members['time'].'<br />'.
                'Name: ' . $members['nick']. '<br />'.
                'Phone #: '. $members['phone']. '</p>';

I'm trying to call the members of a particular subscribership. Included, the join date 'time', the username 'nick', and the phone number 'phone'.

So as this code goes through each array it would automatically convert the unix timestamp (stored in the $members['time']) into a user-friendly time, such as MM-DD-YY.

Any help is greatly appreciated.

jminkler 5th October 2010 10:54 PM

Re: Converting UNIX time
 
Read the manual :)
http://php.net/manual/en/function.date.php

string date ( string $format [, int $timestamp ] )

in other words ... date('Y-m-d', $members['time']);

Big Squid 6th October 2010 12:44 AM

Re: Converting UNIX time
 
Got it! Thanks!


All times are GMT -6. The time now is 11:29 AM.