mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
26 lines
705 B
HTML
26 lines
705 B
HTML
|
<p>请你编写一个程序来计算两个日期之间隔了多少天。</p>
|
|||
|
|
|||
|
<p>日期以字符串形式给出,格式为 <code>YYYY-MM-DD</code>,如示例所示。</p>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>示例 1:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>date1 = "2019-06-29", date2 = "2019-06-30"
|
|||
|
<strong>输出:</strong>1
|
|||
|
</pre>
|
|||
|
|
|||
|
<p><strong>示例 2:</strong></p>
|
|||
|
|
|||
|
<pre><strong>输入:</strong>date1 = "2020-01-15", date2 = "2019-12-31"
|
|||
|
<strong>输出:</strong>15
|
|||
|
</pre>
|
|||
|
|
|||
|
<p> </p>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li>给定的日期是 <code>1971</code> 年到 <code>2100</code> 年之间的有效日期。</li>
|
|||
|
</ul>
|