0

I don't understand why strtotime is returning a date off by a few days.

$expiration = '2015-07-19'; // yyyy-mm-dd
$exp = strtotime($expiration);
$exp = date('F m, Y',$exp);

echo $exp; // returns "July 07, 2015" (NOT the 19th)

What am I missing?

UPDATE: Even if I do this:

echo date('F m, Y');

It says it's August 8 when today is August 21! Why!?!?!?

1
  • see my answer. m is a repesentation of a month use d instead to represent days. F is a full textual representation of a month. Therefore you are using two month representation in your date function Commented Aug 22, 2014 at 3:47

2 Answers 2

1

Here it is: Outputs July 19, 2015. See demo. You are using two characters to represent months in your date function. F and m are textual and numeric representations of a month. So change 'm' to 'd' to represent days. date("F d, Y") e.g. January 01, 2000

$expiration = '2015-07-19'; // yyyy-mm-dd
$exp = strtotime($expiration);
$exp = date('F d, Y',$exp);

echo $exp;

DEMO

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

3 Comments

@JROB F and m are month representations. You are not using a character to represent a day so use change m to d to represent days.
Wow, thank you. It's been a long day I can't believe I did that... thank you!
@JROB It's great to help you bro!
1

Try this

$expiration = '2015-07-19'; // yyyy-mm-dd
$exp = strtotime($expiration);
//$exp = date('F m, Y',$exp);
$exp = date('jS F, Y',$exp);

Output

19th July, 2015

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.