Answers.Body: <p>Figured it out, needed to format the <code>postDate</code> object accordingly:</p>
  
  <pre><code>{% set products = products | supersort('rsortAs', '{ postDate | date("U") }') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-13T19:59:37.850Z
Answers.LastActivityDate: 2020-05-13T19:59:37.850Z
Answers.UserDisplayName: MonkishTypist
Body: <p>In Craft CMS Twig template I am trying to sort Entries by post date using SuperSort.</p>
  
  <p>An old template on Craft CMS 3.0.17.1 PRO is using:</p>
  
  <pre><code>{% set products = products | supersort('rsortAs', '{ postDate }') %}
  </code></pre>
  
  <p>And this works as expected.</p>
  
  <p>But after updating to Craft CMS 3.4.17.1 PRO this is throwing an error:</p>
  
  <pre><code>PHP Recoverable Error – yii\base\ErrorException
  Object of class DateTime could not be converted to string
  </code></pre>
  
  <p>I tried updating to:</p>
  
  <pre><code>{% set products = products | supersort('rsortAs', '{ entry.postDate }') %}
  </code></pre>
  
  <p>But the sorting does not work as expected, ie. nothing is sorted by date.</p>
  
  <p>I saw this <a href="https://craftcms.stackexchange.com/questions/12244/using-supersort-with-date-field">Using Supersort with date field</a> but that is not helpful as I am using the latest plugin version.</p>
  
  <p>I'm missing something or doing something wrong?!</p>
  
Tags: <postdate><plugin-supersort>
Title: SuperSort `rsortAs` error with `postDate`
ThreadText: # SuperSort `rsortAs` error with `postDate`
  
  (Asked by: username_0 on 2020-05-13)
  
  In Craft CMS Twig template I am trying to sort Entries by post date using SuperSort.
  
  An old template on Craft CMS 3.0.17.1 PRO is using:
  
  ```
  {% set products = products | supersort('rsortAs', '{ postDate }') %}
  
  ```
  
  And this works as expected.
  
  But after updating to Craft CMS 3.4.17.1 PRO this is throwing an error:
  
  ```
  PHP Recoverable Error – yii\base\ErrorException
  Object of class DateTime could not be converted to string
  
  ```
  
  I tried updating to:
  
  ```
  {% set products = products | supersort('rsortAs', '{ entry.postDate }') %}
  
  ```
  
  But the sorting does not work as expected, ie. nothing is sorted by date.
  
  I saw this [Using Supersort with date field](https://craftcms.stackexchange.com/questions/12244/using-supersort-with-date-field) but that is not helpful as I am using the latest plugin version.
  
  I'm missing something or doing something wrong?!
  
  **Tags:** postdate, plugin-supersort
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-05-13. Score: 1
  
  Figured it out, needed to format the `postDate` object accordingly:
  
  ```
  {% set products = products | supersort('rsortAs', '{ postDate | date("U") }') %}
  
  ```
  
  
  ---
  
  