Forum Discussion

sean's avatar
sean
Contributor
12 years ago

how to set post time for add message

Hi all,

 

I use API post a message, how to set post_time frmat,i want to set a fied time,exmaple:20-12-08

  • AdamN's avatar
    AdamN
    Khoros Oracle

    Hi Sean,

     

    The dates used with the REST API are always in ISO 8601 format, but that shouldn't matter much when it comes to displaying the date since your users will (likely) never see the actual results of the REST API.

     

    If you're using the Lithium UI, you can adjust the date format via the Community Admin by browsing to System > Date and Time.

     

    If you're creating your own UI elements for the REST API results (ie. a custom component in the community, or an external widget on your .com website), you can get a friendlier version of the date by using the restapi.response_style parameter. Here are some details about that from the REST API JavaDocs:

     

    If a request specifies the parameter restapi.response_style with the value view, the response will include attributes that relate the elements to the standard web interface. The attributes include

    AttributeDescription
    view_href For elements that are associated with a page in the standard web interface, this specifies the URL for that page.
    view_date Included in date/time elements. This provides a date string formatted as expected by the Lithium user associated with the call.
    view_time Included in date/time elements. This provides a time string formatted as expected by the Lithium user associated with the call.

     

    If view_date and view_time don't work for your needs, FreeMarker also provides some date formatting methods which you could use to convert the date into your desired format: 

    http://freemarker.sourceforge.net/docs/ref_builtins_string.html#ref_builtin_string_date

    http://freemarker.sourceforge.net/docs/ref_builtins_date.html

     

    Here's a similar topic with some examples that may be helpful for you:

    http://lithosphere.lithium.com/t5/developers-discussion/How-to-format-date-time-output-nicely/m-p/43600/highlight/true#M1190

    • sean's avatar
      sean
      Contributor

      Hi AdamN,

      view date is no problem. I use the REST API insert record,.

      example:
      community.domain.com/restapi/vc/boards/id/boardid/messages/post?
      message.subject=Title&message.body=Hello Admin&message.post_time=2013-04-20

       

      OR

       

      community.domain.com/restapi/vc/boards/id/boardid/messages/post?
      message.subject=Title&message.body=Hello Admin&message.post_time=2013-04-20 05:10


      i want to save the date "2013-04-20" or "2013-04-20 05:10", how to do?

      • AdamN's avatar
        AdamN
        Khoros Oracle

         

        I don't think there's a parameter named "message.post_time" for that particular method. There is a "message.post_date" parameter listed in the documentation; however, I believe that particular parameter is reserved for internal Lithium use only. I'm going to follow up on getting the documentation updated to reflect this.

         

        So unfortunately, I don't believe you're going to be able to set a specific time when posting a message. Is there a reason you want to set the time differently than the present time? Perhaps there's some other way to approach what you're trying to accomplish.