{"id":5368,"date":"2023-04-12T08:11:43","date_gmt":"2023-04-12T08:11:43","guid":{"rendered":"https:\/\/info.documotor.com\/?page_id=5368"},"modified":"2023-04-12T08:11:43","modified_gmt":"2023-04-12T08:11:43","slug":"add_time","status":"publish","type":"page","link":"https:\/\/info.documotor.com\/?page_id=5368","title":{"rendered":"Add_time"},"content":{"rendered":"\n<p>Adds a specific type of offset to an existing datetime object. <\/p>\n\n\n\n<h3>Syntax<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">datetime add_time(datetime $startDate, number|string $offset, string $offsetType)<\/code><\/pre>\n\n\n\n<p> Adds the $offset of the specific $offsetType to the original $startDate. <\/p>\n\n\n\n<h3>Parameters<\/h3>\n\n\n\n<p><strong>$startDate:<\/strong> The datetime object that should have the $offset added to it.<br><strong>$offset<\/strong>: The number that defines how much offset that should be added to the $startDate-<br><strong>$offsetType:<\/strong> The type of offset that should be added to the $startDate. The different types available are: <\/p>\n\n\n\n<ul><li><code>t<\/code> (ticks)<\/li><li><code>ms<\/code> (milliseconds)<\/li><li><code>s<\/code> (seconds)<\/li><li><code>min<\/code> (minutes)<\/li><li><code>h<\/code> (hours)<\/li><li><code>d<\/code> (days)<\/li><li><code>m<\/code> (months)<\/li><li><code>y<\/code> (years)<\/li><\/ul>\n\n\n\n<h3>Example<\/h3>\n\n\n\n<pre title=\"Data\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json line-numbers\">{\n    \"startDate\": \"2023-01-01T00:00:00.00Z\",\n    \"offset\": 30,\n    \"offsetType\": \"d\"\n}<\/code><\/pre>\n\n\n\n<pre title=\"Transformation\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">{\n    addedTime: add_time(startDate, offset, offsetType),\n    formattedTime: format($.addedTime, 'dd-MM-yyyy', 'en-GB')\n}<\/code><\/pre>\n\n\n\n<pre title=\"Output\" class=\"wp-block-code\"><code lang=\"json\" class=\"language-json line-numbers\">{\n    \"addedTime\": \"2023-01-31T00:00:00Z\",\n    \"formattedTime\": \"31-01-2023\"\n}<\/code><\/pre>\n\n\n\n<p>This example shows how to add 30 days to the date 1st of January 2023. The start date is of the type datetime, the offset is a number, and the offset type is a string identical to one of the types (in this case &#8220;days&#8221;) listed above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adds a specific type of offset to an existing datetime object. Syntax Adds the $offset of the specific $offsetType to the original $startDate. Parameters $startDate: The datetime object that should have the $offset added to it.$offset: The number that defines how much offset that should be added to the $startDate-$offsetType: The type of offset that [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":0,"parent":271,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/5368"}],"collection":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5368"}],"version-history":[{"count":4,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/5368\/revisions"}],"predecessor-version":[{"id":5372,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/5368\/revisions\/5372"}],"up":[{"embeddable":true,"href":"https:\/\/info.documotor.com\/index.php?rest_route=\/wp\/v2\/pages\/271"}],"wp:attachment":[{"href":"https:\/\/info.documotor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}