subtract method

DateTime subtract (Duration duration)

Returns a new DateTime instance with duration subtracted from this.

DateTime today = new DateTime.now();
DateTime fiftyDaysAgo = today.subtract(new Duration(days: 50));

Notice that the duration being subtracted is actually 50 * 24 * 60 * 60 seconds. If the resulting DateTime has a different daylight saving offset than this, then the result won't have the same time-of-day as this, and may not even hit the calendar date 50 days earlier.

Be careful when working with dates in local time.

Implementation

external DateTime subtract(Duration duration);
{"cc_re__cc_re__cc_by_sa_4_0": ["lementation</span></h2>\n      <pre class=\"language-dart\"><code class=\"language-dart\">external DateTime subtract(Duration duration);</code></pre>\n    </section>\n\n  </div> <!-- /.main-content -->\n\n  <div id=\"dartdoc-sidebar-right\" class=\"col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right\">\n  </div><!--/.sidebar-offcanvas-->\n\n</main>\n\n<footer>\n  <span class=\"no-break\">\n    Dart\n      2.6.0-edge.f309ca5faaf7956bf45d091b5111cff1b729cee4\n  </span>\n\n  &bull;\n<span class=\"copyright no-break\">\n  <a href=\"http://creativecommons.org/licenses/by-sa/4.0/\">cc license</a>\n</span>\n\n</footer>\n\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js\"></script>\n<script src=\"static-assets/typeahead.bundle.min.js\"></script>\n<script src=\"static-assets/highlight.pack.js\"></script>\n<script src=\"static-assets/URI.js\"></script>\n<script src=\"static-assets/script.js\"></script>\n<script>\n  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement("], "copyright__copyright__copyright": ["d from this.\n\nDateTime today = new DateTime.now();\nDateTime fiftyDaysAgo = today.subtract(new Duration(days: 50));\n\nNotice that the duration being subtracted is actually 50 * 24 * 60 * 60 seconds. If the resulting DateTime has a different daylight saving offset than this, then the result won't have the same time-of-day as this, and may not even hit the calendar date 50 days earlier.\n\nBe careful when working with dates in local time.\n\nImplementation\n\nexternal DateTime subtract(Duration duration);"]}