createdDate field with less information

5 posts by 2 authors in: Forums > CMS Builder
Last Post: September 24, 2013   (RSS)

Hi,

I´ve been using the createdDate field to show the date of the creation of the records. I´m getting the date in this format: "2013-09-22 14:11:56"  It´s possible to get with  this field only "2013-09-22" without the  hours, minutes and seconds?

Carlos Pinedo

By Daryl - September 23, 2013

Hi Carlos Pinedo,

You can get the date without the hours, minutes, and seconds from the createdDate field by using explode(). Ex:

$dateArray       = explode(" ", $record['createdDate']);
$dateWithoutTime = $dateArray[0];

Let us know if this works for you.

Cheers!

Daryl

Daryl Maximo
PHP Programmer - interactivetools.com

By Daryl - September 24, 2013 - edited: September 24, 2013

Hi Carlos Pinedo,

You're not exploding the correct variable for createdData, try this:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/observat/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records from 'info_docs'
list($info_docsRecords, $info_docsMetaData) = getRecords(array(
'tableName' => 'info_docs',
'perPage' => '1',
'loadUploads' => true,
'allowSearch' => false,
));

foreach ($info_docsRecords as $infoDocsRecord){

$dateArray       = explode(" ", $infoDocsRecord['createdDate']);
$dateWithoutTime = $dateArray[0];
echo $dateWithoutTime;

}


?>

Cheers!

Daryl

Daryl Maximo
PHP Programmer - interactivetools.com

Awesome, it works now.

Thanks a lot