I'm trying to show date where record inserted using recordtime field.
but when i user
did i do something wrong?
but when i user
echo date('d-m-Y',strtotime('{recordtime}'));
it alway return 01-01-1970 .did i do something wrong?
Hi dion,
Where are you trying to do this? You can only use the { } syntax in the email template.
Bob
Where are you trying to do this? You can only use the { } syntax in the email template.
Bob
i'm using it at ChonoConnectivity, at "body".


<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="0">
<tbody>
<tr<?php if ($i % 2) echo ' style="background-color: #EBEBEB;"';?>>
<td style="width: 10%;">
<?php
echo date('d-m-Y',strtotime('{recordtime}'));?>
</td>
<td style="width: 15%;">{region}</td>
<td style="width: 15%;">{shift}</td>
<td style="width: 5%;">{Lalin}</td>
<td style="width: 15%;">{tunai}</td>
<td style="width: 15%;">{PPC}</td>
</tr>
</tbody>
</table>
<?php $i++ ?>
it should be like this:
echo date('d-m-Y',strtotime($row->recordtime));
I've tried the above code along with everything else under the sun and can't get the correct format to show up.
I'm trying to get a strftime format of "%B %e, %Y, %l:%M %p CT" to show up in the header box with no luck. My last futile effort was:
any help appreciated
-John
I'm trying to get a strftime format of "%B %e, %Y, %l:%M %p CT" to show up in the header box with no luck. My last futile effort was:
<?php
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$query = sprintf('SELECT `recordtime` FROM %s WHERE `cf_user_id` = %d',
$db->nameQuote('#__chronoforms_xxxx'),
$user->id
);
$db->setQuery($query);
$result = $db->loadResult();
$t = strtotime("$result");
echo "Last Saved on ", date("%B %e, %Y, %l:%M %p",strftime($t));
?>
any help appreciated
-John
Hi bullfn33,
This line will cause some problemsThe , will break the PHP; it needs to be a .
The PHP date() function doesn't use % in its format string.
The PHP strftime() function does use %; but the first parameter is a format string, not a timestamp. [/list:o]
Please try
Bob
This line will cause some problems
echo "Last Saved on ", date("%B %e, %Y, %l:%M %p",strftime($t));
[list=a]Please try
echo "Last Saved on ". strftime("%B %e, %Y, %l:%M %p", $t);
Bob
I tried the line above but it seems there is some conversion problem to the $t variable. I tried a bunch of different ways to get it to convert to a readable time but all I get is December 31, 1969 or August 21, 1970. The last thing I tried was this
<?php
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$query = sprintf('SELECT `recordtime` FROM %s WHERE `cf_user_id` = %d',
$db->nameQuote('#__chronoforms_xxxx'),
$user->id
);
$db->setQuery($query);
$result = $db->loadResult();
$result = date('YY-MM-DD - HH:MM:II');
$t = strtotime($result);
echo "Last Saved on ". strftime("%B %e, %Y, %l:%M %p", $t);
?>
Hi bullfn33,
Please check the PHP manual for the correct settings to use with PHP functions: date('YY-MM-DD - HH:MM:II') returns 20112011-JunJun-WedWed - 1414:JunJun:11 which probably isn't what you intended.
Also notice that strtotime() will interpret a date as being in US 'month day year' format if that makes sense so 11-06-22 will be interpreted as 6 Nov 2022
Bob
Please check the PHP manual for the correct settings to use with PHP functions: date('YY-MM-DD - HH:MM:II') returns 20112011-JunJun-WedWed - 1414:JunJun:11 which probably isn't what you intended.
Also notice that strtotime() will interpret a date as being in US 'month day year' format if that makes sense so 11-06-22 will be interpreted as 6 Nov 2022
Bob
This topic is locked and no more replies can be posted.