Try this:
<?php
$currentdoc =$modx->documentObject['createdon'];
$format = "%B %e %Y";
if($currentdoc !=0){
$date= strftime($format,$currentdoc);
}else{
$date ="No date available";
}
// set the placeholder here for usage later in your document or whatever
$modx->setPlaceholder('Cdate',$date); // [+Cdate+]
// optionally output the results
$output ="";
$output .="[+Cdate+]";
return $output;
?>
@oldwebdude
This works for me.
Are you possibly using RTE like TinyMCE to edit content ?
If so, disable it and try again...
@tkfm
BINGO! Yup - thanks tkfm - that was it. As soon as I set editor to none and re-entered the snippet call - problem solved.
-
☆ A M B ☆
- 24,524 Posts
If you really want/need the editor for a document with complex snippet calls, you can use a chunk, and put the snippet call in the chunk. Many snippets now come with an option to put configuration parameters in an external config file, which also avoids most problems with the editor trashing your snippet tags.
The snippet DateTime could be improve for non english language.
Date formatting is always a pain for accentuated charset..
What about this ?:
<?php
/**
* DateTime
* Makes a date and time... thingy. Now even thingier.
* Original author Alex Butter.
* 1.02 amended 08Aug06 by Paul Gregory, inspired by doze & breezer.
* 1.03 by Aramaki 27 Jan 2008
* [!DateTime? &format=`%B %e %Y` ×tamp=`[*createdon*]`!]
* 1.04 Charset improvement by Eric Lacomblez 29 Sep 2010
* [!DateTime? &format=`%B %e %Y` ×tamp=`[*createdon*]` &local_time=`fr_FR`!]
*/
/* force local_time for correct php date format */
if(!isset($local_time)) {
$local_time = "fr_FR";
}
setlocale (LC_TIME, $local_time);
if(!isset($format)) {
$format="%d-%m-%Y %H:%M:%S";
}
if(!isset($timestamp)) {
$timestamp=time();
}
if(!isset($shift)) {
$shift=0;
}
// Do proper charset
if ($modx->config['modx_charset']=='UTF-8') {
return utf8_encode(strftime($format, $timestamp+$shift+$modx->config['server_offset_time']));
} else {
return strftime($format, $timestamp+$shift+$modx->config['server_offset_time']);
}
?>
Thank you
Schtroumpf Grognon - Grouchy Smurf
---------------------------------
Faites pas attention.. - Don't pay attention
http://www.dzi-neo.net