Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the current timestimp in each day in the week #185

Open
ajax13 opened this issue Nov 25, 2013 · 11 comments
Open

Get the current timestimp in each day in the week #185

ajax13 opened this issue Nov 25, 2013 · 11 comments

Comments

@ajax13
Copy link

ajax13 commented Nov 25, 2013

HI, In week-days.html template, for each iteration can we get the corresponding timestamp or day ? (i can't find a way to dump 'events' an underscore variable)

@stokes84
Copy link

You can dump anything from your json data into each template. If you were using the example data which provides "start": 12039485678000, // Milliseconds you could spit that out using <%= event['start'] %> but you'll probably want to format it inline using something like this..

var date = new Date(<%= event['start'] %>);
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var formattedTime = hours + ':' + minutes + ':' + seconds;

@ajax13
Copy link
Author

ajax13 commented Dec 2, 2013

thx stokes84 , but I want the current day, not the event start day, For exemple, in 2 / 12/ 2003 and i have an event from 10:00 to 11:00 => i want to get "2" ( the number of day) :)

@stokes84
Copy link

stokes84 commented Dec 2, 2013

the method above will work, use date.getDay();, year, month, day, they're all in the starttime and endtime just have to parse em out. If you're using php to generate your json you could also add another field and pull that instead of generating a javascript function every loop iteration to spit out a day.

@ajax13
Copy link
Author

ajax13 commented Dec 4, 2013

thx @stokes84 ans sorry for the bad example above : i want to get the number for the current day in case when i have an event between tow days: from 02 / 12/ 2003 to 03 / 12/ 2003 OR from 03 / 12/ 2003 and 04 / 12/ 2003 (and the current day is "03") => :///////

@steliosph
Copy link
Contributor

Then you will need to do this in PHP

date("w", strtotime($DATE);
// 0 (for Sunday) through 6 (for Saturday)

This will return the current day.

Not entirely sure of what you are asking though.

@Serhioromano
Copy link
Owner

Would it be possible to subtract start from end?

var days = (event['end'] - event['start']) * 86400000;

@ajax13
Copy link
Author

ajax13 commented Jan 31, 2014

thx @steliosph and @steliosph, but that is not what i need. So i reformulate the situation. There is a way to get the value of each week days from week-days.html template . Example: the week 5 of 2014: we have: 27, 28, 29, 30, 31, 1 and 2 as value of ech day.

In week-days.html template (week 5 of 2014):

<% _.each(events, function(event, iterator){ %>
      // get the current day for this week ( the first one is Monday `27`)
<% }); %>

@Serhioromano
Copy link
Owner

I did not not get you.

@ajax13
Copy link
Author

ajax13 commented Feb 4, 2014

thx @Serhioromano, i made some updates in the example above. i hope that's become clear now.

@Serhioromano
Copy link
Owner

But you have getTitle for calendar. You do not need to have that inside component. You may add any HTML element and populate it with title through getTitle.

https://github.com/Serhioromano/bootstrap-calendar/blob/master/js/app.js#L25

Anyway you can see how to create title in that exact method

https://github.com/Serhioromano/bootstrap-calendar/blob/master/js/calendar.js#L789-806

@ajax13
Copy link
Author

ajax13 commented Feb 4, 2014

thx, but i'm not interested with Title value. I just want to get the current day number of the current week(example 27) as explained in the above loop. i want to make a custom js scripts and i need those values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants