News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SSI and calendar...

Started by Jim R, March 30, 2007, 03:39:49 PM

Previous topic - Next topic

Jim R

I seem to come back to the calendar issue a lot.  ssi_recentEvents.

As SSI code collects information from the calendar, it's processing the date as year,month,day.  How do I change it so it lists month,day,year?  I've tried a couple of places, but I'm not getting any results.

Furthermore, is there a way to list the name of the month opposed to it being listed numerically?

Thanks.

青山 素子

If you have it return an array, you can use PHP's date-formatting functions to get what you need. The date is returned in the start_date and end_date values.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Jim R

I don't know what that means.   ??? :)

Jim R

OK...found what you're referring to, but it's not working.  It doesn't even recognize it.

Jim R

The dates stored in the calendar database are actual dates, not the regular time stamps.  Would your suggestion apply to that?   

青山 素子

#5
If you aren't sure how to do this, look over SSI.php and the ssi examples. They provide plenty of good information and sample code. Once you get past simple displaying of items you'll need to know a little PHP so you can manipulate the info to your liking. The SSI script handles the complex stuff for you, so you don't need to be an expert. If you aren't familiar with PHP, look over some tutorials to get some familiarity with it.

MySQL handles dates as YYYY-MM-DD, but you can easily manipulate that in PHP as you wish. Look at PHP's Date and Time Functions for your tools to do so.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Jim R

I've been dealing with SSI with SMF for about two years now, and my manipulating it isn't getting anything accomplished.  I've made many modifications in my SSI.  I have a logical understanding of PHP but not a practical application of it.  I can often find the logic in what is written and play around with it to get what I want.  It doesn't work that way though.

I found the PHP date functions per your first post.  The formatting didn't work within the SSI, and the examples don't provide anything what I need.  I've hit an area where what I'm doing isn't working.  I'm asking for additional information on how to do it.  I'm not able to make heads or tails of what you're providing.

ssi_examples don't even provide anything which show dates, just event/holiday/birthday listings.  I've changed it so it shows a date, but as I noted in my original post it shows the as YYYY-mm-dd.  I want it to show mm-dd-YYYY.  Can you help me get that done?

I'd also like make it show the month in letters, not numbers, such as Jan, Feb, Mar.  I changed the mm to MM, but it didn't work with what ssi_recentEvents is pulling from the database.

Jim R

OK...found something else with a broader search that addresses my issue.  It's a bit of a fix but not all the way.  Here is the code I'm working with now. 


'start_date' => strftime('%m-%d-%Y', strtotime($row['startDate']) ),
'end_date' => strftime('%m-%d-%Y', strtotime($row['endDate']) ),


It's allowing me to change the order of how the date is displayed, but in wanting to express months in letters instead of numbers, changing the 'm' to 'M' isn't working.

Any thoughts?

青山 素子

Here is something I did really quick using the array return for ssi_recentEvents(). It isn't the prettiest, but it should give you a starting point.


<?php
$events
= ssi_recentEvents(5, 'array');

//Loop through array to get our events
echo '<ul>';

foreach (
$events as $eventday => $array)
{
foreach ($array as $event)
{
//Make our dates into something a little more fancy
$start_date = strftime('%d %B %Y', strtotime($event['start_date']));
$end_date = strftime('%d %B %Y', strtotime($event['end_date']));


echo '<li><a href="', $event['href'], '">', $event['title'], '</a> - ', $start_date, ' to ', $end_date, '</li>';
}
}

echo
'</ul>';
?>
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


myaicons

halleluyah!!!!!

weeks of searching and hairpulling... and there it is!



now if i can only get it to show in the correct date order....

anybody???
i scratch your back you scratch my back...
funny thing about my back is its located on my...

Advertisement: