" /> Unfortunately the displayed information looks like YYYY-MM-DD, but I need the date format DD.MM.YYYY ...My idea:Echo variable $birthday2 (like above) and previously define something like:$birthday2 = $user_info->cb_birthday formatted to DD.MM.YYYYNow what's the correct php syntax for that line?Thanks in advance and best regards,Kepp"> Tiny php snippet needed for date format - Forums

Forums

Tiny php snippet needed for date format

kepp 21 Jul, 2010
Sorry to disturb you guys...
I need a tiny and easy php snippet (one or two lines), because my bad php skills already come to an end here. 😶

Situation:
1. I have a database entry called "cb_birthday". Data is abvously saved in the format YYYY-MM-DD.
2. I can sucessfully display this birthday in a field of my ChronoForms from.
<?php echo $user_info->cb_birthday; ?>" />

Unfortunately the displayed information looks like YYYY-MM-DD, but I need the date format DD.MM.YYYY ...

My idea:
Echo variable $birthday2 (like above) and previously define something like:
$birthday2 = $user_info->cb_birthday formatted to DD.MM.YYYY


Now what's the correct php syntax for that line?

Thanks in advance and best regards,
Kepp
GreyHead 21 Jul, 2010
Hi kepp,

Use the PHP strtotime function to create a timestamp; then date() to format it.

Something like
<?php echo date('m-d-Y', strtotime($user_info->cb_birthday)); ?>" />

Not tested and may need debugging.

Bob
kepp 21 Jul, 2010

Something like

<?php echo date('m-d-Y', strtotime($user_info->cb_birthday)); ?>" />


That's it, thanks a lot!
Those $25 were worth every cent of it! 😀
betta1 25 Jul, 2010
Acually needed this for myself. Good quest. kepp and thanks for the answer Greyhead 😀
This topic is locked and no more replies can be posted.