View Full Version : Separate post.postdate
Hy ,
I have a little probleme, I want to put the date of a post on the left of the thread title and I wnat that on 3 lines. the first line to be the day , the second to be the month and the third to be the year. the problem is I dont' know how to separete the post.postdate variable in three parts day , month, year. Or if somoane can give me another ideea how to put the date in three separate lines without puting each part in his own div, table , etc
Thanks!
Lynne
02-26-2012, 09:34 PM
Use the function vbdate on the postdate timestamp. That function should be in /includes/functions.php
looks like this is over my head, maybe I am lucky and an addon will apear with something similar. Thanks for the help Lynne
Exactly where do you want it to be (which template)?
I want to use it in postbit_legacy
OK, you could create a plugin using hook location postbit_display_complete and code like this:
$post['day'] = vbdate('l', $post['dateline']);
$post['month'] = vbdate('F', $post['dateline']);
$post['year'] = vbdate('Y', $post['dateline']);
and then in the template use {vb:raw post.day}, {vb:raw post.month}, and {vb:raw post.year}.
To see what the 'l', 'F', and 'Y' mean and what other things you could put there, see this page in the php manual: http://us2.php.net/manual/en/function.date.php
If you haven't created a plugin before, see the vb manual here: https://www.vbulletin.com/docs/html/main/add_plugin
I've created the plugin and it works but it displays the date january 1970, how I make it to show the date of the post.
Oops, 'postdate' should have been 'dateline' (in 3 places) - I fixed the code above.
Mark.B
02-27-2012, 06:01 PM
edyy is hoping to recreate the "Calendar" style date boxes I use on my forum.
Here is exactly what I have at the same hook location:
$post['month'] = date('M', $post['dateline']);
$post['month'] = strtoupper($post['month']);
$post['day'] = date('d', $post['dateline']);
$post['year'] = date('Y', $post['dateline']);
The only real difference in mine is the addition of a line of code to convert the month to upper case.
Make sure the plugin is at the correct location AND you have it set to "Active".
I use it to create the below:
136723
Works perfect. Thank you for your help.
--------------- Added 1330369427 at 1330369427 ---------------
Yes I try to recreate your calendar, I hope you don't mind. The plugin kh99 made works perfect.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.