note 106816 deleted from function.strpos by tularis
| From: | tularis@php.net | Date: | Fri, 09 Dec 2011 15:46:14 +0000 |
| Subject: | note 106816 deleted from function.strpos by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185000@lists.php.net to get a copy of this message | ||
Note Submitter: marcelo at programandophp dot net
Reason: useless
----
You can use it this way:
<?php
function strtounixtime($input = ""){
if ($input instanceof DateTime){
$date['Y'] = date_format($input, "Y");
$date['m'] = date_format($input, "m");
$date['d'] = date_format($input, "d");
$date['H'] = date_format($input, "H");
$date['i'] = date_format($input, "i");
$date['s'] = date_format($input, "s");
return mktime($date['H'], $date['i'], $date['s'],
$date['m'], $date['d'], $date['Y']);
}elseif (!is_string($input)){
return false;
}elseif (strpos($input, "/") === true) {
return false;
}else{
$date['Y'] = date_format(date_create($input), "Y");
$date['m'] = date_format(date_create($input), "m");
$date['d'] = date_format(date_create($input), "d");
$date['H'] = date_format(date_create($input), "H");
$date['i'] = date_format(date_create($input), "i");
$date['s'] = date_format(date_create($input), "s");
return mktime($date['H'], $date['i'], $date['s'],
$date['m'], $date['d'], $date['Y']);
}
}
echo strtotime("+1 day", strtounixtime("2011-12-08 16:45:15"));
?>