Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. Yes,you are right.

     

    I had tried it but the implementation/logic was wrong-I tried now a different logic and it worked.

    Probably,creating a topic about it,was not even necessary.

  2. I have created a loop that creates a dropdown menu, a menu of timestamps, for reasons of clarity though I have created this fiddle http://jsfiddle.net/fiddlehunt/5WVKz/ where the menu is comprised of numbers 1-10,

     

    And here is the problem:

    As you will see in the fiddle the append() method is used.

    The problem is that whenever the function that creates the loop gets called...the created numbers are added to the numbers that where created with the previous function call.

     

    So. when the menu is opened(and if for example the function has been called twice) I see two times 1-10.

     

    Unfortunately I cannot replicate the behavior with jsfiddle.

     

    How can I fix it?

  3.  

    the issue I believe is that JavaScript will truncate the leading 0. Try this

    var adjminuts = (minutes === 0) ? "00" : minutes;

    Yes,that will do.Actually I had resort to this solution even before I see your post.

  4. I have concluded to this code:

    var minutes= j.getMinutes();var adjminuts = (minutes === 0) ? 00 : minutes;

    The problem though is that when minutes === 0,adjminutes takes always the value 0,not 00 as I want to.

     

    WHat can I do here? It seems that JS,when we have a number comprised of many zeros,than js will just print 0 in the browser.

  5. I have made a considerable progress in the direction I wish.

     

    I have one small question though.

    I use getMinutes to "grab" the minutes of a given timestamp.

     

    Suppose we have 10:00-getMinutes will output 0,I want 00 though.

    What can I do?

    Add the second O my self with custom code?

  6. I will look into the library you mentioned.

     

    For now I have managed to do what I want...take a look at this fiddle: http://jsfiddle.net/fiddlehunt/ZP74r/

     

    It might be convenient to make calculation when working with timestamps but I do not know if it is possible

    to set the hour/minute(as shown in the fiddle) with these.

     

    It is possible to set hour/min with UNIX timestamps-my fault I did not saw it earlier.

  7. he's saying, if you have the "pretty" date, then use the Date constructor with those values, and then call getTime on it.

     

    If you need to figure out the difference between times, you can subtract one timestamp from the other.

    The above being said is it correct to assume I must set the "pretty date" at the beginning of the day.

    I mean whatever calculation needs to be done must be done on the "pretty date",not in the UNIX timetamp.

  8. If you want to get a timestamp for Tue, 10 Jun 2014 01:00:00 GMT, then create a date object with those values and get the timestamp.

    So,,,in other words...you are saying to convert the timestamp into time format like the above and then use this in the date constructor...which in turn will give a new timestamp(modified).

  9. Is there any js method to alter a UNIX timestamp?

     

    All theses set methods seem not to have any effect on timestamps per se.

     

    Suppose I have 1402376400.

     

    How I can set it to 1402376100....

     

    I can use simple arithmetic of course to do my job....but these would require some extra calculations.

     

    The goal is this:

    Given a timestamp...set the time in the beginning of the day.

     

    Suppose I have in UNIX timestamp form this date: Tue, 10 Jun 2014 17:34:53 GMT

    I want to convert it to this:Tue, 10 Jun 2014 01:00:00 GMT

     

    Is there a js code/method available to help in this direction?

     

    One issue(important to consider) is that the given timestamp varies and no standard calculation would be appropriate here,That is why I was asking if a js method existed for that.

  10.  

    so it sounds like might need to delimit the value then, so you can break it apart on the server side

    <option value="11232535345|234345345">10:00AM - 11:00AM</option>

    Τhat wont'be necessary cause I use 2 menus,one for the start date and the other for the end date.Just go and see the fiddle.

  11. Oh I get it. Your timestamp is the starting point and you need to show a bunch of dates in intervals after that till a determined endtime.

     

    No....the dropdown option values(timestamps) must span all the 24h.

    The start/end dates I mention are selected by the user when clicking in the calendar...at that point a dialog box appears with selected dates depicted in two dropdown menus. The user though...might decide to choose other dates from the menus...just like in outlook.com calendar.

     

    Here is the fiddle http://jsfiddle.net/fiddlehunt/5xsxP/...go to weekview and click a slot to see the dialog box...see the HTML also...

  12. i think we were all under the impression that you had an array, but if you don't then you don't need a loop.

     

     

    No...I do not have an array...but I still think a loop is needed

     

    It's just like I described here:If you have 2 date objects for the start and end, that's all you need. It's just a basic for loop. The valueOf method of a date object returns the timestamp. Each time through the loop you increment the loop counter by the number of milliseconds in a half hour.

    There is a misunderstanding here.The start and end date are not the start and end of the 24h period as the dropdown option values must cover but

    the start and end of an event...that can be 10:00 to 11:00 for example.

  13. are you asking how to loop through your data to dynamically generate an select tag with options, setting the value to a timestamp, and the display value to the formatted date? Because if you have the data, then I'm not sure what you're stuck on?

    Yes...what you describe above is what I want to achieve.

    Now to the problem itself.

     

    I have one piece of data...a specific point in time(the specific timestamp)...I do not know how to use that and construct the loop-that is the problem.

     

    It might simple to you but not to me.I am trying to find a solution to it myself too.

  14. Ι do understand the logic but I am having difficulty implementing it.

    So far I have concluded that the first step will be this:

     var inmilise=1401840000*1000;//this is a timestamp multiplied by 1000...        var d = new Date(inmilise);

    The above prints a date...in this specific example it is this:

    6/4/2014 3:00:00 AM

     

    The above info must somehow be used in the loop...but the question is how specifically I must do this?

  15. It sounds like you're asking for a for loop that starts at the first timestamp, ends at the last, and each time through the loop it gets incremented by 30 minutes.

    Yes,you are correct. Timestamps for the whole 24h-and always based on a specific day/month.The one the user clicked.

    The already present timestamps I suppose can help somehow-revealing some info about the day/month.

  16. well...I just made some progress.In JS,I maybe able to pull this off with JS,it might not be necessary to resort to PHP.

     

    The first obstacle to create the dropdown menu is to get UNIX timestamps. Now, I managed to get the timestamps(start/end date of an event,it's duration in other words).

     

    So this is the first step.

    Now,,,,having these new data,how I could proceed and construct the dropdown?

    The point being is that after the popup appears(with the selected dates) the user will be able to alter the start/end dates.just like in outlook.com calendar.

     

    In other words....by having 2 timestamps is it possible to construct the other timestamps that will correspond to different times-there must be 30min intervals?

     

    And these(of course) newly constructed timestamps will be placed in the option values of the menu.

     

    Can JS help in the above?

  17. well...I decided to post in this forum cause the application uses backbone to send event data to the server(that includes the timestamp).

     

    I am going to post in the PHP forum cause I thing the HTML rendering(the dropdown menu with the timestamps) must be PHP's job.

     

    It is a thought I just made and the future will tell if it is the correct solution.

     

    I agree of course that the dropdown menus must be unix timestamps.

  18. If you're trying to convert a string to a date object then it will need to be in a format that the date constructor understands, or else you need to parse the string and split it up into individual pieces for the constructor.http://stackoverflow.com/questions/5619202/converting-string-to-date-in-jshttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

    You are saying "to convert a string to a date object". To be honest I do not know if that is even necessary.

     

     

    Let me describe the problem again.I want to build a dropdown menu of times where each one will correspond to a different timestamp(and this will be depicted in the option value of the menu option selected.)

     

    First of all I do not know if this must be done with JS or PHP...that is another issue to consider also.

×
×
  • Create New...