title: Convert time to string
body: <p>Guys i am stuck I am trying to convert a String to date time using my own Format:</p>
  
  <pre><code>&lt;?php
  require('qs_connection.php');
  require('qs_functions.php');
  
  $sDay = $_POST['sDay']; 
  $sMonth = $_POST['sMonth'];
  $sYear = $_POST['sYear'];
  $sHour = $_POST['sHour'];
  $sMin = $_POST['sMin'];
  
  $eDay = $_POST['eDay'];
  $eMonth = $_POST['eMonth'];
  $eYear = $_POST['eYear'];
  $eHour =  $_POST['eHour'];
  $eMin = $_POST['eMin'];
  
  function num($n){
      $n=$n;
      if ($n&lt;9){
          $n="0"."$n";
      }
      else{
          $n=$n;
      }
      return $n;
  }
      function month($mt){
      switch($mt){
          case "Jan":
              return "01";
          case "Feb":
              return "02";
          case "Mar":
              return "03";
          case "Apr":
              return "04";
          case "May":
              return "05";
          case "Jun":
              return "06";
          case "Jul":
              return "07";
          case "Aug":
              return "08";
          case "Sep":
              return "09";
          case "Oct":
              return "10";
          case "Nov":
              return "11";
          case "Dec":
              return "12";
          break;
      }
  }
      $startDate = $sYear."-".month($sMonth)."-".num($sDay)." ".num($sHour).":".num($sMin).":00";
      $endDate = $eYear."-".month($eMonth)."-".num($eDay)." ".num($eHour).":".num($eMin).":00";
  
      $startDate = date_create_from_format("Y-m-d H:i:s", $startDate);
      $endDate = date_create_from_format("Y-m-d H:i:s", $endDate);
      $today = date("Y-m-d H:i:s");
  
  
  
  
  
      if(($today &gt;($endDate || $startDate)) || ($endDate &lt; ($startDate || $toady))){
          echo "Can not save";
      }
      else{
          $result = mysql_query("Select votetimeid From votetime ORDER BY votetimeid DESC LIMIT 1");
              while ($db_field = mysql_fetch_assoc($result)){
                  $id = $db_field['votetimeid'];
              }
              $id+=1;
  
      echo "Start: $startDate &lt;br&gt;Today: $today &lt;br&gt;End: $endDate";
  
      }
  ?&gt;
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre><code>Catchable fatal error: Object of class DateTime could not be converted 
  to string in     C:\wamp\www\mvote\admin\settime.php on line 80
  </code></pre>