The general code takes an .xml file and searches for this: <date>2012-09-21</date>This the preg_match statement.

What I'm trying to do with drupal is have the article that's being posted to a drupal run website is $node->created = $article_timestamp;

But it outputs: 1969-12-31

This is -1 in unix time, the moment before the Unix epoch began. I set $article_timestamp to -1 just to check.

Why is it doing this? I'm trying to have the article authored on the date it was posted, but I can't figure out how. Another variant is setting $article_timestamp = strtotime($matches[0]) but that sets the date to the current day.

What is weird is that if I do this: $fixed_date="2012-02-03"; $article_timestamp = strtotime($fixed_date); drupal_set_message(t("from fixed to variable:".$article_timestamp));

It works properly. If someone could help me out, I'd really appreciate it. And if you need any more info, I'll be glad to give it.

It's not $article_date that's the problem. It outputs what it should. The problem seems to be in the strtotime(matches[0]) part of the code, wherever it shows up. Either I do this:$article_timestamp =date('Y-m-d', strtotime($matches[0]));and I get the day 1969-12-31

or I use $article_timestamp = strtotime($matches[0])and I get posted by drupal the time()

Basically what I'm after is if I have an article with a date in the format 'Y-m-d', I want the article to be posted with that day, not a day before the unix epoch began and not the current time. What was given is useful to know, but I already knew that $article_date != NULL.

Actually, that's an interesting question, and why I was so frustrated. Before the change you gave me, this line:drupal_set_message(t("date content: ".$matches[0]));

did in fact output the date formated like so: 2012-09-24

To go back a bit, this is the line in the xml file that I'm retrieving with the first pregmatch:<date>2012-09-24</date>

With the preg match line being:preg_match('/<date>.+?<\/date>/',$article_contents,$matches);

and the rest of the original code being:

$article_date = $matches[0];$article_timestamp =strtotime($matches[0]); //one of the two variants I used, see the first postdrupal_set_message(t("Article timestamp: ".$article_timestamp)); //outputs time() without the extra pregmatchdrupal_set_message(t("date content: ".$matches[0])); //outputs the date formatted as 'Y-m-d'

So it seems there is still something to work through here. Why did $article_date output the date? Did something somewhere get rid of the xml tags automatically?