2

I've been using string to time in my website to format the date stamps held in a database and up until now the method I'm using has been fine up to this point. Here is the code:

$memberdate = $member['date'];
$memberdate = date('jS F Y', strtotime($memberdate));

The initial $membersate value is 1381742596 - The output value is 1st January 1970

Does anyone know a reason why this would be working for all other pages/scripts but not now?

3
  • because 2nd date parameter has to be an integer (so $memberdate would be enough). strtotime() requires a string, like "2013-11-07" or "+1 day" Commented Nov 7, 2013 at 15:30
  • var_dump($member['date']); Commented Nov 7, 2013 at 15:30
  • Ah yes, thanks @Asenar - I just had a look at my other date stamps and they're in 20131107 format so that's why it works for those - Thanks again Commented Nov 7, 2013 at 15:33

1 Answer 1

4

strtotime() is used, when you are converting ie. "2013-11-07 16:29:30" to its integer value.

But you already have it as unix_timestamp (integer value), so you dont need to use strttotime().

$memberdate = date('jS F Y', $member['date']);
Sign up to request clarification or add additional context in comments.

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.