| Start |
|---|
| getTimestamp
this will out put an integer indication the seconds that have elapsed since 00:00:00 UTC, Thursday, 1 January 1970. |
| setDate
this example sets the date to be the twenty-fifth of July, 2015, it will produce the following result: |
| Add or Subtract Date Intervals We can use the class DateInterval (opens new window) to add or subtract some interval in a DateTime object. See the example below, where we are adding an interval of 7 days and printing a message on the screen: This will output (running on Aug 1st, 2016): Samara says: Seven Days. You'll be happy on 2016-08-08. We can use the sub method in a similar way to subtract dates This will output (running on Aug 1st, 2016): Samara says: Seven Days. You were happy last on 2016-07-25. |
| Create DateTime from custom format PHP is able to parse a number of date formats (opens new window). If you want to parse a non-standard format, or if you want your code to explicitly state the format to be used, then you can use the static Object oriented style Procedural style |
| Printing DateTimes PHP 4+ supplies a method, format that converts a DateTime object into a string with a desired format. According to PHP Manual, this is the object oriented function: The function date() takes one parameters - a format, which is a string FormatThe format is a string, and uses single characters to define the format:
UsageThese characters can be used in various combinations to display times in virtually any format. Here are some examples: ProceduralThe procedural format is similar: Object-OrientedProcedural Equivalent |
| Create Immutable version of DateTime from Mutable prior PHP 5.6 To create Prior PHP 5.6 you can use: |
Read Article
https://develop.horje.com/learn/1434/reference