<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic parseDate giving &amp;quot;invalid format&amp;quot; error in ThingWorx Developers</title>
    <link>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963766#M67321</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have two date values in String format like "&lt;SPAN&gt;2024-07-25 19:41:27.0000000 +00:00"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to calculate the time difference in between so I want to change them to date format. so&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;used the code below but it gives me the invalid format error. Parsing neglects the year:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let StartDate =&amp;nbsp;"2024-07-25 19:41:27.0000000 +00:00"&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let sdf = "yyyyMMddHHmmsszzz";&lt;BR /&gt;result = parseDate(StartDate,sdf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Invalid format: "2024-07-25 19:41:27.0000000 +00:00" is malformed at "-07-25 19:41:27.0000000 +00:00"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I even tried the slice the string, but I got the same error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let StartDate =&amp;nbsp;"2024-07-25 19:41:27.0000000 +00:00"&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let ShortStartDate = StartDate.slice(0,19)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let sdf = "yyyyMMddHHmmsszzz";&lt;BR /&gt;result = parseDate(ShortStartDate,sdf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Invalid format: "2024-07-25 19:41:27" is malformed at "-07-25 19:41:27"&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 28 Jul 2024 22:15:33 GMT</pubDate>
    <dc:creator>oaslan</dc:creator>
    <dc:date>2024-07-28T22:15:33Z</dc:date>
    <item>
      <title>parseDate giving "invalid format" error</title>
      <link>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963766#M67321</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have two date values in String format like "&lt;SPAN&gt;2024-07-25 19:41:27.0000000 +00:00"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to calculate the time difference in between so I want to change them to date format. so&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;used the code below but it gives me the invalid format error. Parsing neglects the year:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let StartDate =&amp;nbsp;"2024-07-25 19:41:27.0000000 +00:00"&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let sdf = "yyyyMMddHHmmsszzz";&lt;BR /&gt;result = parseDate(StartDate,sdf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Invalid format: "2024-07-25 19:41:27.0000000 +00:00" is malformed at "-07-25 19:41:27.0000000 +00:00"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I even tried the slice the string, but I got the same error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let StartDate =&amp;nbsp;"2024-07-25 19:41:27.0000000 +00:00"&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let ShortStartDate = StartDate.slice(0,19)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;let sdf = "yyyyMMddHHmmsszzz";&lt;BR /&gt;result = parseDate(ShortStartDate,sdf);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Invalid format: "2024-07-25 19:41:27" is malformed at "-07-25 19:41:27"&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2024 22:15:33 GMT</pubDate>
      <guid>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963766#M67321</guid>
      <dc:creator>oaslan</dc:creator>
      <dc:date>2024-07-28T22:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: parseDate giving "invalid format" error</title>
      <link>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963782#M67323</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://community.ptc.com/t5/user/viewprofilepage/user-id/207729"&gt;@oaslan&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly find the below attached date conversion code which working for me.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;let StartDate = "2024-07-25 19:41:27.0000000 +00:00";

let ShortStartDate = StartDate.slice(0,19);

///**// DateTime Format ///**///
let sdf = "yyyy-MM-dd HH:mm:ss";

result = parseDate(ShortStartDate,sdf);
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Arun C&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 05:26:56 GMT</pubDate>
      <guid>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963782#M67323</guid>
      <dc:creator>Arun_C</dc:creator>
      <dc:date>2024-07-29T05:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: parseDate giving "invalid format" error</title>
      <link>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963832#M67339</link>
      <description>&lt;P&gt;Dear Arun,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked, thank you for your support. It seems the sdf format should be properly defined.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 09:34:16 GMT</pubDate>
      <guid>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963832#M67339</guid>
      <dc:creator>oaslan</dc:creator>
      <dc:date>2024-07-29T09:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: parseDate giving "invalid format" error</title>
      <link>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963973#M67352</link>
      <description>&lt;P&gt;It's probably good to know that the parseDate uses the format from the Joda library and examples can be seen here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html" target="_blank"&gt;https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Note there are a few articles related to parseDate in the support.ptc.com, and specifically &lt;A href="https://www.ptc.com/en/support/article/CS219448" target="_blank" rel="noopener"&gt;this&lt;/A&gt; one explains how to use it and links to the site above.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 17:22:16 GMT</pubDate>
      <guid>https://community.ptc.com/t5/ThingWorx-Developers/parseDate-giving-quot-invalid-format-quot-error/m-p/963973#M67352</guid>
      <dc:creator>VladimirRosu</dc:creator>
      <dc:date>2024-07-29T17:22:16Z</dc:date>
    </item>
  </channel>
</rss>

