I have a DateTime object, initialized with a specific date:
$inputString = '06102013';
$myDate = DateTime::createFromFormat('mdY', $inputString);
Now I want to give it out in different Formats, using
$myFormat = 'd.m.Y';
$myDate->format($myFormat);
This works perfectly fine for all formats up until the point where I say:
$myFormat = 'U';
Then $myDate->format('U');
contains just the current timestamp (the actual time when the function is called). But how do I get the timestamp from the original input date, $inputString
in my case?
If this is important: I'm using PHP 5.3, but plan on upgrading soon.
Edit: Forgot to mention that
$myDate->getTimestamp();
also returns the time of calling, not the original time that the DateTime
object was created with!