format date

Help with installation and general calendar setttings

format date

Postby savefilez » Fri Jul 23, 2010 8:16 am

Hello, i'm trying to display the US format mm/dd/yy into text box using the code at http://forum.ajaxavailabilitycalendar.com/viewtopic.php?f=22&t=274 but it keeps putting year/month/day as input.. anyone know how to format the date? thanks. :(
savefilez
 
Posts: 1
Joined: Fri Jul 23, 2010 1:39 am

Re: format date

Postby chris » Fri Jul 23, 2010 8:56 am

Hi,
You would need to modify the JavaScript function so tha it splits the date up into parts and then create a new var with the date parts in the order that you want them.
Something like this:
Code: Select all
function activate_dates(){
  var dateStart=document.id('date');
  $$('li.clickable').each(function(el){
    if(!el.hasClass('booked')){
      el.addEvent('click',function(){
        var dateParts=this.id.split('-');     
        var dateFormat=dateParts[1]+'-'+dateParts[2]+''-'+dateParts[0];
        dateStart.set('value',dateFormat);
      }).setStyle('cursor','pointer');
    }
  })
}

Note - I have not tested this code.

Hope that points you in the right direction ;)

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: format date

Postby 69developer » Mon Jan 31, 2011 6:40 pm

I am wanting so when you hover over calendar date, it will display mm/dd/year.

I tried the above code, but it still shows the date format as 31/1/2011.

I tried different numbers in the dateparts but it never reformatted the date.
69developer
 
Posts: 1
Joined: Mon Jan 31, 2011 6:37 pm

Re: format date

Postby MicoX » Mon Mar 05, 2012 1:16 pm

only one thing, a comma in the line must be removed
Code: Select all
var dateFormat=dateParts[1]+'-'+dateParts[2]+''-'+dateParts[0];

must be
Code: Select all
var dateFormat=dateParts[1]+'-'+dateParts[2]+'-'+dateParts[0];


:D
MicoX
 
Posts: 5
Joined: Mon Mar 05, 2012 1:10 pm

Re: format date

Postby chris » Mon Mar 05, 2012 2:07 pm

Well spotted, thanks :)

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: format date month display

Postby Razoredger » Mon May 19, 2014 6:03 pm

I would like to display the month in text format in the date picker field but no matter how I modify the date_format it still outputs numbers only.
ie: 27/01/2014
Here is the code I understnd must be modified.
Code: Select all
    // format date
function get_cal_update_date($id_item){
   if(AC_DATE_DISPLAY_FORMAT=="us")   $date_format   = "%m-%d-%Y";
   else                         $date_format   = "%d-%m-%Y";


I have replaced "m" by mm, mmm, M, F....I have tried every PHP parameter I could find, but still no luck, display format is 27/01/2014. I have looked at $month, data-date.. no clue

So please where do I need to modify things and how to display 27 January 2014 instead of 27/01/2014 ?

Not sure if this formu is still alive, but throwing this SOS bottle out to sea...
Best Regards :)
User avatar
Razoredger
 
Posts: 12
Joined: Tue Aug 30, 2011 4:09 pm
Location: Indian Rocks Beach

Re: format date

Postby Razoredger » Tue May 20, 2014 1:47 am

This still doesn't work, but I succeeded in getting the month name instead of number. The only problem is when I click a date in July is displays January :o
User avatar
Razoredger
 
Posts: 12
Joined: Tue Aug 30, 2011 4:09 pm
Location: Indian Rocks Beach

Re: format date

Postby chris » Wed May 21, 2014 11:15 am

Hi,
Which date display are you referring to exactly?

Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: format date

Postby chris » Wed May 21, 2014 11:17 am

If you are referring to the date that is displayed when you hover over the dates in the calendar, try the following:

In ac-includes > functions.inc.php, replace these lines (ln 126 & ln 127):

Code: Select all
if(AC_DATE_DISPLAY_FORMAT=="us")   $date_format   =   $month."/".$day_counter."/".$year;
        else                           $date_format   =   $day_counter."/".$month."/".$year;


with:
Code: Select all
$date_format= strftime('%d %B %Y', strtotime("".$month."/".$day_counter."/".$year.""));


Chris
User avatar
chris
Site Admin
 
Posts: 1088
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: format date

Postby Razoredger » Wed May 21, 2014 9:52 pm

Thank you, it worked! I modifed it to keep the same structure since my calender uses both US and French date formatting. I understood I needed to use strftime and strotime but was clueless as to where to put those puzzle pieces.
In answer to your questions. about which dates, they are the dates that are clicked in the calendar and displayed within a form for inputs dateStart and dateEnd. This is discussed elsewhere on the forum under the integration with a form topic.

To clarify with in functions.inc.php this is, here's a wider swath of code including what you just helped me with:

Code: Select all
//   format date for db modifying - the date is passed via ajax
      $date_db      =   $year."-".sprintf("%02s",$month)."-".sprintf("%02s",$day_counter);
        //   format date for display only
        if(AC_DATE_DISPLAY_FORMAT=="us")
            $date_format  = strftime('%B %d %Y', strtotime("".$month."/".$day_counter."/".$year.""));
// format for FR and ES
        else $date_format  =  strftime('%d %B %Y', strtotime("".$month."/".$day_counter."/".$year.""));


Thank you again. :D
User avatar
Razoredger
 
Posts: 12
Joined: Tue Aug 30, 2011 4:09 pm
Location: Indian Rocks Beach


Return to Support

Who is online

Users browsing this forum: No registered users and 0 guests

cron