Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session 3BBK P1 Module05-May-2007 : [‹#›] Date Manipulation.

Similar presentations


Presentation on theme: "Session 3BBK P1 Module05-May-2007 : [‹#›] Date Manipulation."— Presentation transcript:

1 Session 3BBK P1 Module05-May-2007 : [‹#›] Date Manipulation

2 Session 3BBK P1 Module05-May-2007 : [‹#›] Unix Epoch..? The easiest way to handle dates in PHP is using UNIX timestamps. A UNIX timestamp is the number of seconds since the UNIX Epoch. The Epoch is 1 st Jan :00 GMT.

3 Session 3BBK P1 Module05-May-2007 : [‹#›] Get current time Use the time() function to get current or relative time.

4 Session 3BBK P1 Module05-May-2007 : [‹#›] Display a time.. To display a time use the date() function along with a format string. Format strings:

5 Session 3BBK P1 Module05-May-2007 : [‹#›] String to timestamp To convert a string to date, use strtotime()

6 Session 3BBK P1 Module05-May-2007 : [‹#›] String to timestamp Note that strtotime() assume a US date format on string such as mm/dd/yyyy, so some modifications may be required.

7 Session 3BBK P1 Module05-May-2007 : [‹#›] What about dates before 1970? Negative timestamps are not consistently supported in PHP. Therefore we cannot use timestamps when using dates that might be before 1970.

8 Session 3BBK P1 Module05-May-2007 : [‹#›] The full information.. We have looked at a sub-selection of this information. If you want to do something with dates.. This is the place to start looking.

9 Session 3BBK P1 Module05-May-2007 : [‹#›] HOE 7 : Handling Dates

10 Session 3BBK P1 Module05-May-2007 : [‹#›] Review Know what an integer UNIX date is. Can manipulate dates in PHP: creating, displaying, parsing from string data.


Download ppt "Session 3BBK P1 Module05-May-2007 : [‹#›] Date Manipulation."

Similar presentations


Ads by Google