?
Solved

Strtotime returning -1

Posted on 2008-10-19
1
Medium Priority
?
226 Views
Last Modified: 2008-10-23
Can you tell me why strtotime is returning -1 for the value '2008-10-15T18:20:24-07:00'. Trying to get a unix time stamp for that string.

0
Comment
Question by:qwertq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
Scripting_Guy earned 500 total points
ID: 22754126
-1 means that it failed to parse the string (prior to php 5.something, they changed that so the function returns false in more recent versions).

This also means, that strtotime won't help you here. this might:

[code]
<?php

$string = '2008-10-15T18:20:24-07:00';
preg_match ('/([\d]+)-([\d]+)-([\d]+)T([\d]+):([\d]+):([\d]+).*/s', $string, $hits);
$timestamp = mktime ($hits[4], $hits[5], $hits[6], $hits[2], $hits[3], $hits[1]);
echo $timestamp;
?>
[/code]
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question