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 CarlosPinedo - September 23, 2013 - edited: September 24, 2013

Hi Daryl, I added the code at the top of my page, but I think I'm missing something, because it didn't worked. Here's my code

<?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,
));

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

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>

<body>

<?php echo $record['createdDate'] ?>

</body>
</html>


What is wrong with it?

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