![]() Use the following code snippet to subtract 2 hours from current date and time using PHP. The following example code helps you to subtract time from current DateTime or a specific date-time. You can use these two functions together to subtract time form the current date using PHP. On the other hand, the strtotime() function converts string formatted DateTime into Unix timestamp. The date() function formats a local date and time, and returns a formatted string. DATE_RFC3339 - Same as DATE_ATOM (since PHP 5.1.Subtract time (hours, minutes, and seconds) from date can be easily done using the date() and strtotime() function in PHP.DATE_COOKIE - HTTP Cookies (example: Friday, 12-Apr-13 15:52:01 UTC).U - The seconds since the Unix Epoch (Janu00:00:00 GMT)Īnd the following predefined constants can also be used (available since PHP 5.1.0):.The offset for timezones west of UTC is negative (-43200 to 50400) T - Timezone abbreviations (Examples: EST, MDT).P - Difference to Greenwich time (GMT) in hours:minutes (added in PHP 5.1.3).O - Difference to Greenwich time (GMT) in hours (Example: +0100).I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise).e - The timezone identifier (Examples: UTC, GMT, Atlantic/Azores).s - Seconds, with leading zeros (00 to 59).i - Minutes with leading zeros (00 to 59).H - 24-hour format of an hour (00 to 23).h - 12-hour format of an hour (01 to 12).G - 24-hour format of an hour (0 to 23).g - 12-hour format of an hour (1 to 12).y - A two digit representation of a year.Y - A four digit representation of a year.L - Whether it's a leap year (1 if it is a leap year, 0 otherwise). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |