1

I have something in my database that shows the time when the users who signed up on my recorded .. When the person makes the user saves the script (time ();) currently in the database under the variable name "REGTIM".

If I use echo to print it out, I get for example:

     1375202508

How can I make this a date if it is possible? or for example as mentioned below.

for example: 08/06/2013 2:11

3 Answers 3

2

You can use date() function with timestamp mention in the second argument,

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

or in your case:

date('m/d/Y H:m', 1375202508);

you can read more on http://php.net/manual/en/function.date.php

Sign up to request clarification or add additional context in comments.

Comments

2

You could have got the answer to that with a little bit of searching. But here you go:

echo date('m/d/Y h:m', 1375202508); // 07/30/2013 10:07 -- 12-hour format
echo date('m/d/Y H:m', 1375202508); // 07/30/2013 22:07 -- 24-hour format

See the documentation for more options: http://php.net/manual/en/function.date.php

Comments

0

that's probably just a unix timestamp, so use FROM_UNIXTIME() and DATE_FORMAT() to do the conversion/formatting inside your query, or use date() in PHP to work with the timestamp directly.

e.g.

echo date('d/m/Y h:m', $timestamp)

or

SELECT DATE_FORMAT('%d/%m/%y %h:%m', FROM_UNIXTIME(REGTIM)) 

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.