Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Perl, PHP, Python & Ruby Development
- :
- Re: Formatting SF DateTime in php
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Formatting SF DateTime in php
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-05-2012 02:09 PM
Is there a simple way to format a date and time currently displayed as 2012-11-06T23:00:00.000Z as dd/mm/yyyy hh:mm ? I've looked at various php formatting functions but can't find one suitable. I could do this by string manipulation but hope there is a simpler approach !
Thanks
Solved! Go to Solution.
Re: Formatting SF DateTime in php
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-13-2012 08:27 PM
You can use a combination of PHP's strtotime and date functions.
$oldDate = '2012-11-06T23:00:00.000Z';
$newDate = date('d/m/Y G:i', strtotime($oldDate));
echo $newDate;You can find information on PHP's date function (including formatting string parameters) at http://www.php.net/manual/en/function.date.php. Note that you might need to use gmdate instead which returns a GMT datetime. Change the 'G' to a 'g' if you want to display the time in 12 hour format instead of 24 hour format, and you can use an 'a' or 'A' at the end if you want to add the am/pm or AM/PM to the end.
Salesforce.com Certified Developer
Re: Formatting SF DateTime in php
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-14-2012 05:59 AM
Thanks - I'd done it by some rather crude string manipulation. This is the elegant solution I'd hope for.
Thanks again.

