Get the App
SLTechnology News&Howtos  ›  Development  › 

How does php calculate the number of weeks between dates

Shulou Source: shulou.com Published: 2022-06-03 17:23:16 11月13日 Update

This article will explain in detail how php calculates the number of weeks between dates. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

DateTime::createFromFormat-- date_create_from_format: parses the date-time string according to the given format

Object-oriented style

Public static DateTime::createFromFormat (string $format, string $time, DateTimeZone $timezone =?): DateTime

Process style

Date_create_from_format (string $format, string $time, DateTimeZone $timezone =?): DateTime

1. Parse the date-time string given by the time parameter into a new DateTime object according to the format given by the format parameter.

2. Parameter format: the format string used when parsing the date-time string.

Most of the formats are consistent with those in the date () function.

Time: a string used to represent the date and time.

The timezone:DateTimeZone object that represents the time zone that needs to be used when parsing date-time strings.

If you omit the timezone parameter and the string time representing the date and time does not contain the time zone information, the system's current time zone will be used as the time zone for the parsed result object.

Note:

If the time parameter is in UNIX timestamp format (for example: 946684800), or if it already contains time zone information (for example: 2010-01-28T15:00:00+02:00), then both the timezone and the system's current time zone will be ignored.

Example

Tags: Date time character string time zone format parameter object between article information time more system style good practical consistent content function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Linux OPPO Reno Microsoft Shulou Technology