Log in

View Full Version : vbdate


cagatayh
11-24-2012, 01:26 PM
I want to show date stamp different in postbit. I dont wanna change default date stamp..

So i made plugin.


<hookname>postbit_display_start</hookname>
<phpcode><![CDATA[

$tarih = vbdate('m-d-Y' $thread['dateline']);
echo $tarih;
]]></phpcode>
</plugin>


Result is: m-d-y

Any help ?

Thanks

kh99
11-24-2012, 01:48 PM
This line is missing a comma, it should be:

$tarih = vbdate('m-d-Y', $thread['dateline']);

cagatayh
11-25-2012, 01:42 PM
This line is missing a comma, it should be:

$tarih = vbdate('m-d-Y', $thread['dateline']);

echo $tarih;

result still is: m-d-Y

:o

kh99
11-25-2012, 02:36 PM
OK, I think the problem is that if you have a language with a locale set, then vbdate uses strftime() to format the date rather than date(), and strftime() uses different format specifications. I think the solution is to set the 4th parameter of vbdate() to 'false' to make it use date(). There's also a 3rd parameter that says whether or not to use "yesterday" and "today" for recent dates, so you have to specify that as well (the default is 'false').

So, try this:

$tarih = vbdate('m-d-Y', $thread['dateline'], false, false);

cagatayh
11-25-2012, 06:23 PM
OK, I think the problem is that if you have a language with a locale set, then vbdate uses strftime() to format the date rather than date(), and strftime() uses different format specifications. I think the solution is to set the 4th parameter of vbdate() to 'false' to make it use date(). There's also a 3rd parameter that says whether or not to use "yesterday" and "today" for recent dates, so you have to specify that as well (the default is 'false').

So, try this:

$tarih = vbdate('m-d-Y', $thread['dateline'], false, false);

It works but the result is:

10-18-201210-18-2012

kh99
11-25-2012, 06:30 PM
Hmm...you're echoing it at the postbit_display_start hook, so it's going to be displayed once per post. (You probably wouldn't want to use echo at all, but I assumed you were doing that as a test).

cagatayh
11-25-2012, 06:46 PM
Hmm...you're echoing it at the postbit_display_start hook, so it's going to be displayed once per post. (You probably wouldn't want to use echo at all, but I assumed you were doing that as a test).

Yep it's for test. I want to use $tarih in showthread. What do you suggest for <hookname> ?

kh99
11-25-2012, 06:56 PM
Maybe try showthread_complete.

cagatayh
11-25-2012, 07:22 PM
Maybe try showthread_complete.

it works. Thanks