This function uses the TZ environment variable (if any) to calculate the timestamp. PHP 5.1.0 has an easier way to determine the time zone of All/dateTime functions used. This process is explained on the page of the date_default_timezone_get () function.
The string to be parsed. In PHP 5.0.0, it is not allowed in microseconds, since PHP 5.0.0 they are allowed, but ignored.
Now
Which are timestamps used as the calculation base relative to the date.
Return value
If a timestamp is returned successfully, otherwise, FALSE is returned. Before PHP 5.1.0, this function will return failure-1.
Returns a timestamp on success,FALSEWww.111cn. netotherwise. Previous to PHP 5.1.0, this function wowould return-1On failure.
Now let's look at the function instance for converting strtotime to time.
<? Php Tutorial
// Function
Function nextWeeksDay ($ date_begin, $ nbrweek)
{
$ Nextweek = array ();
For ($ I = 1; $ I <= $ nbrweek; $ I ++) {// 52 week in one year of coursewww.111cn.net
$ Nextweek [$ I] = date ('d d m y ', strtotime (' + '. $ I. 'Week', $ date_begin ));
}
Return $ nextweek;
}
/// End function
/// Example of a select date
// Var
$ Date_begin = strtotime ('06-05-2010 '); // D Day Month Year-like function format.
$ Nbrweek = 52;
// Call function
$ Result = nextWeeksDay ($ date_begin, $ nbrweek );
// Preview
For ($ I = 1; $ I <= $ nbrweek; $ I ++ ){
Echo '<br>-'. $ result [$ I];
}
?>
<? Php
$ Str = 'not Good ';
// Previous to PHP 5.1.0 you wowould compare with-1, instead of false
If ($ timestamp = strtotime ($ str) === false ){
Echo "The string ($ str) is bogus ";
} Else {
Echo "$ str =". date ('l dS o f y h: I: s A', $ timestamp );
}
?>
<? Php
Echo strtotime ("now "),"";
Echo strtotime ("10 September 2000 "),"";
Echo strtotime ("+ 1 day "),"";
Echo strtotime ("+ 1 week "),"";
Echo strtotime ("+ 1 week 2 days 4 hours 2 seconds "),"";
Echo strtotime ("next Thursday "),"";
Echo strtotime ("last Monday "),"";
?>
This is a quick function compute "working day" during a year ". "Workday" refers to the holidays specified in the $ array that have no weekends and no holidays. I left the reader for more than one year.
Function get_working_days ($ to_date ){
$ Holidays = array (
1 => array (10), // 2011...
2 => array (11 ),
3 => array (21), //... 2011
4 => array (2010...
5 => array (3, 4, 5 ),
6 => array (),
7 => array (19 ),
8 => array (11,12, 13 ),
9 => array (20, 23 ),
10 => array (11 ),
11 => array (3, 23 ),
12 => array (23) //... 2010
);
For ($ to_date, $ w = 0, $ I = 0, $ x = time (); $ x <$ to_date; $ I ++, $ x = strtotime ("+ $ I day ")){
If (date ("N", $ x) <6 &! In_array (date ("j", $ x), $ holidays [date ("n", $ x)]) $ w ++;
}
Return $ w;
}
// Usage:
Echo get_working_days (strtotime ("2011-01-08 "));