Date Field Enhancements

5 posts by 2 authors in: Forums > CMS Builder
Last Post: January 19, 2010   (RSS)

By yusuke - January 15, 2010

It doesn't seem to display as the below format.
"2010, 1, 16"

FYI: I am a CMSB user in Japan. 1 is January, 2 is Feb. and so on.
It really should be -- 2010nen 1gatu 16nichi (nen=year, gatu=month, nichi=day)

Re: [yusuke] Date Field Enhancements

By Chris - January 18, 2010 - edited: January 18, 2010

Hi yusuke,

To display dates like this on your website, you'll need to change this:

<?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?>

to this:

<?php
$d = $record['date'];
echo date('Y', $d) . "nen " . date('n', $d) . "gatu " . date('j', $d) . "nichi";
?>


You may need to change the name of the date field (in red above) to match your own configuration.

I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [yusuke] Date Field Enhancements

By Chris - January 19, 2010

Hi yusuke,

We're using the somewhat-magical php function strtotime(), which is very restricted in the input it takes. While there are many ways to enter that date, I'm afraid you can't enter it with Japanese characters. Here are some examples of how you can enter Feb 1, 2010:

2010/2/1
2010-2-1
2/1/2010
1-2-2010

You can also use leading zeros on the day and/or month.

The "Preview" date is hardcoded to output in English.

We could change how any of this works through custom programming. Let me know if you're interested in that.

I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Date Field Enhancements

By yusuke - January 19, 2010

Thanks Chris!

It's clear now [cool]