Jump to content


Photo

How to set date field through API?


  • Please log in to reply
2 replies to this topic

#1 Lars282

Lars282

    Newbie

  • Members
  • PipPipPip
  • 76 posts
  • 3

  • LocationLondon, UK; Frankfurt, Germany

Posted 25 June 2012 - 10:20 AM

Hey!

How do I set the date field when adding pages through the API? It defaults to today's date when using the admin, and I want to achieve the same when uploading through the API.

Thanks,

Lars

#2 ryan

ryan

    Hero Member

  • Administrators
  • 5,753 posts
  • 3102

  • LocationAtlanta, GA

Posted 25 June 2012 - 10:38 AM

You can do it like this to set it to today's date/time:

$page->date = time();

Or like this to set a specific date/time, you can use any format that PHP's strtotime() function accepts, like this:

$page->date = "2012-06-25 11:36:00";


#3 Lars282

Lars282

    Newbie

  • Members
  • PipPipPip
  • 76 posts
  • 3

  • LocationLondon, UK; Frankfurt, Germany

Posted 25 June 2012 - 10:39 AM

Great, thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users