0

I want to get this date's timestamp from string. I'm trying:

DateTime::createFromFormat("Y-m-d", "2015-05-18T23:45:21.604Z");

But it returns nothing. I don't know which format is this.

5
  • 1
    Just look up the format specifiers: php.net/manual/de/function.date.php Commented Jul 8, 2015 at 21:39
  • you might wanna check this: stackoverflow.com/questions/6238992/… The first answer splits the process in two pices. With that the debugging should be easier. Commented Jul 8, 2015 at 21:40
  • the problem is I don't know the format. I can use substr() to get only first chars from date string, but guess this is not the correct way to do this Commented Jul 8, 2015 at 21:46
  • You ask a new question, but you don't even end your last question: stackoverflow.com/q/31302585/3933332 Commented Jul 8, 2015 at 21:48
  • Can you give more information on where did you get that Date string? Commented Jul 8, 2015 at 21:57

1 Answer 1

1

try this,

$date = date_create_from_format('d/M/Y:H:i:s', '2015-05-18T23:45:21.604Z');
$date->getTimestamp();
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.