MyBB Community Forums

Full Version: php's strtotime help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I have a form field returning the following string

2011-09-28 16:45

that is stored in $datetime local varaible

and I use PHP's strtotime() to try to get a Unix timestamp for that date

$orig_dateline = strtotime($datetime);

but $orig_dateline is always empty. It does not return FALSE (PHP >= 5.1.0) or -1 (PHP < 5.1.0) so its not failing.

This is in a MyBB Plugin I am working on, and the time functions in MyBB appear to be working fine, so its not a server issue.

I can parse the $datetime variable just fine via

	$datetime_parts = explode(" ",$datetime);
	$date_parts = explode("-", $datetime_parts[0]);
	$time_parts = explode(":", $datetime_parts[1]);

and if I print_r() these two arrays, they contain the proper values. I have even taken those arrays and pushed them into mktime() and even cast to (INT) each variable in the mktime() function and still no result.


Any thoughts?
n/m

its working now, for some reason die($orig_dateline); is not outputting anything,but if I echo it first, then push an empty die(); the resultant is valid.

strange.....
Quote:If status is a string, this function prints the status just before exiting.

If status is an integer, that value will be used as the exit status and not printed. Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully.

Note: PHP >= 4.2.0 does NOT print the status if it is an integer.

PHP: exit - Manual
i dont think i had ever realized that. i usually die() with strings or print_r() of arrays/objects then die() during debugging .

it is strange though, that a value outside the permissible exit code range is not output. i can see not outputting acceptable exit codes, but not dumping integers outside the range is weird to me.
That's why I always use die("".$var); to make sure it gets output
(2011-08-18, 05:06 AM)pavemen Wrote: [ -> ]it is strange though, that a value outside the permissible exit code range is not output. i can see not outputting acceptable exit codes, but not dumping integers outside the range is weird to me.
Not really; they clarify that in the note.