Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Date display format

 

 


squeazel
New User

Jul 5, 2008, 3:04 PM

Post #1 of 2 (372 views)
Shortcut
Date display format Can't Post

I'm having difficulty getting entry dates to display properly.

As a test, I have the following in my code:


Code
<?php echo date("t F Y", $record['date']); ?><?php echo $record['date'] ?>


Sample output from the above looks like this:

31 January 19702008-06-28 00:00:00

So, on the right, the correct date is being pulled in, however somehow I am not translating it properly, and the date via the date function is generic, rather that what's in the CMS.

Any thoughts?


Dave
Staff / Moderator


Jul 5, 2008, 4:52 PM

Post #2 of 2 (366 views)
Shortcut
Re: [squeazel] Date display format [In reply to] Can't Post

squeazel, welcome to the CMS Builder forum! :)

The code generator should automatically create a line of code that does this for you like the following:
Date: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?><br/>

The missing step is the strtotime(), just add the code in red:
<?php echo date("t F Y", strtotime($record['date'])); ?>

Here's how that works (it's not required to know this but just in case you're curious).
- MySQL stores dates like this: 2008-06-21 20:11:17
- The strtotime() converts it to a 'unix timestamp' like this 1214104277 which is the number of seconds since 1970
- The date() function lets you specify a date format but requires the date as a unix timestamp so it knows exactly which date you mean.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4