Solved

Strtotime returning -1

Posted on 2008-10-19
1
210 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
1 Comment
 
LVL 3

Accepted Solution

by:
Scripting_Guy earned 125 total points
Comment Utility
-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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now