Format Date
4 posts by 3 authors in: Forums > CMS Builder
Last Post: February 7, 2008 (RSS)
By Djulia - January 7, 2008 - edited: January 7, 2008
Hi,
I seek to translate a date on my page.
It is possible to modify the format directly in the page.
<?php echo date("l t F Y", strtotime($pageRecord['autoPublishStartDate'])) ?>
Saturday 31 January 2008
But, I do not know how to obtain the days and years in a foreign language.
For example (in spanish) :
Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre
Lunes,Martes,Miercoles,Jueves,Viernes,Sabado,Domingo
and
Ene,Feb,Mar...
Lun,Mar,Mie...
There is a possible solution ?
Thank you for your assistance.
Julia
I seek to translate a date on my page.
It is possible to modify the format directly in the page.
<?php echo date("l t F Y", strtotime($pageRecord['autoPublishStartDate'])) ?>
Saturday 31 January 2008
But, I do not know how to obtain the days and years in a foreign language.
For example (in spanish) :
Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre
Lunes,Martes,Miercoles,Jueves,Viernes,Sabado,Domingo
and
Ene,Feb,Mar...
Lun,Mar,Mie...
There is a possible solution ?
Thank you for your assistance.
Julia
Re: [Djulia] Format Date
By Dave - January 7, 2008
Julia,
It looks like the php date() function doesn't support non-english languages. I've made a note to research this further. We'll have to switch to something else in the future that easily supports multiple languages.
In the meantime I've written a function for you called spanishDate() that has a list of word replacements and attached it to this post. You can include it in your page (include "spanishDate.php";") or add it to viewer_functions.php.
I've added the spanish months and weekdays (hope I got them right) and you can add anything else you need to it. It works just like the date function but makes those replacements. So you can call it like this:
Or specify a format (it uses a default format if you don't specify one, you'll see it in the file).
And instead of "Sunday 14 October 2007" it outputs "Domingo 14 Octubre 2007".
Give that a try and let me know if it works for you. Also, in your format use "j" not "t". "j" is the day of the month (14), "t" is the total days in the month (31).
Hope that helps!
It looks like the php date() function doesn't support non-english languages. I've made a note to research this further. We'll have to switch to something else in the future that easily supports multiple languages.
In the meantime I've written a function for you called spanishDate() that has a list of word replacements and attached it to this post. You can include it in your page (include "spanishDate.php";") or add it to viewer_functions.php.
I've added the spanish months and weekdays (hope I got them right) and you can add anything else you need to it. It works just like the date function but makes those replacements. So you can call it like this:
<?php echo spanishDate($pageRecord['autoPublishStartDate']); ?>
Or specify a format (it uses a default format if you don't specify one, you'll see it in the file).
<?php echo spanishDate($pageRecord['autoPublishStartDate'], "l j F Y"); ?>
And instead of "Sunday 14 October 2007" it outputs "Domingo 14 Octubre 2007".
Give that a try and let me know if it works for you. Also, in your format use "j" not "t". "j" is the day of the month (14), "t" is the total days in the month (31).
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com
Re: [Dave] Format Date
By Djulia - January 8, 2008
Thank you Dave for your assistance. [:)]
Your solution works marvelously well.
My English does not allow me to express, as I would wish it, how your CMS is formidable.
But, I recommend it absolutely !!!
And your assistance makes the difference with the concurrent solutions.
Really, cheer and thank you !
Julia
Your solution works marvelously well.
My English does not allow me to express, as I would wish it, how your CMS is formidable.
But, I recommend it absolutely !!!
And your assistance makes the difference with the concurrent solutions.
Really, cheer and thank you !
Julia
Re: [Djulia] Format Date
By jsv - February 7, 2008
Very helpfull indead, I have added the Dutch translations.