Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated
Welcome the Technical Support section. Help us in assisting you by providing us with a concise and descriptive elaboration of your issues. Be specific and if possible, provide us with a step-by-step instruction in replicating your problem.

Echo Data -> Date

10 years 1 month ago
  • Marco's Avatar
    Topic Author
  • Marco
  • Offline
  • Fresh Boarder
  • Posts: 64
  • Thank you received: 0
Licenses:
JomSocial Expired Socialize Expired

Hi,

i want to display a custom field (Format: DATE) at an other place in the Profile-template so in insert something like this:

$cuser = CFactory::getUser();
$data = $cuser->getInfo('FIELD_hochzeit');
echo $data;

But at the output the time is also indludet like 2013-11-16 23:59:59.

How can i remove the time from this value?


And what template renders the custom fields? So maybe i want to hide some fields in "over me" tab and display them at an other place?!

Thanks
Marco

10 years 1 month ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

Hi Marco,

You can try use this code :

$data = date('Y-m-d',strtotime($data'))

for more information you can see the date functions from here php.net/manual/en/function.date.php

You can find the template profile page inside this components/com_community/templates/modules/profile

10 years 1 month ago
  • Marco's Avatar
    Topic Author
  • Marco
  • Offline
  • Fresh Boarder
  • Posts: 64
  • Thank you received: 0
Licenses:
JomSocial Expired Socialize Expired

Hi Dimas,

thanks, but i don´t know how to include your snippet in the field array ...

Can you write an example please? Everything i try generates a blank page :(


Thanks
Marco

10 years 1 month ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

Hi Marco,

sorry my code was wrong it should be like this :

$cuser = CFactory::getUser();
$data = $cuser->getInfo('FIELD_hochzeit');
$data = date('Y-m-d',strtotime($data))
echo $data;

10 years 1 month ago
  • Marco's Avatar
    Topic Author
  • Marco
  • Offline
  • Fresh Boarder
  • Posts: 64
  • Thank you received: 0
Licenses:
JomSocial Expired Socialize Expired

Thanks, this code generates the correct format:

$cuser = CFactory::getUser();
$data = $cuser->getInfo('FIELD_hochzeit');
$data = date('Y-m-d',strtotime($data))[b][u][color=#ff0000];[/color][/u][/b]
echo $data;

But now the Date is not correct :(

The correct format Date is: 16/11/2013
And the Snippet shows: 1970-01-01


Regards
Marco

10 years 1 month ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

can you try this :

echo $cuser->getInfo('FIELD_hochzeit')

what do you get?

10 years 1 month ago
  • Marco's Avatar
    Topic Author
  • Marco
  • Offline
  • Fresh Boarder
  • Posts: 64
  • Thank you received: 0
Licenses:
JomSocial Expired Socialize Expired

This output nothing ...

10 years 1 month ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

Hi Marco,

when you create new Cuser Object, please make sure you already login to jomsocial page, or you pass the userId manually like this :

$cuser = CFactory::getUser($userId);

10 years 1 month ago
  • Marco's Avatar
    Topic Author
  • Marco
  • Offline
  • Fresh Boarder
  • Posts: 64
  • Thank you received: 0
Licenses:
JomSocial Expired Socialize Expired

Hi,

it is a little bit strange with this date-field, because all other fields can display much easier. But with the code in the post above it shows a date (but not the correct).

I´m still logged in and used this code with the user id, so i think that issn´t the issue.

Thanks
Marco

10 years 1 month ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

Please make sure the field type is correct or not "FIELD_hochzeit"

10 years 1 month ago
  • Marco's Avatar
    Topic Author
  • Marco
  • Offline
  • Fresh Boarder
  • Posts: 64
  • Thank you received: 0
Licenses:
JomSocial Expired Socialize Expired

:-) ups ... my mistake ...

This code work fine!

<?php
 $cuser = CFactory::getUser();
$data = $cuser->getInfo('hochzeit');
$data = date('Y-m-d',strtotime($data));
echo $data;
?>

Thank you very much
Best Regards
Marco

10 years 1 month ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

great!! glad to know that

Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW