Jump to content

Getting The Day Of The Month


jimfog

Recommended Posts

Then the onclick would take that reference number, date? display maybe reformatted from 20111225 to 25/12/2011 and display, then the reference 20111225 (or whatever you decide to use) would be stored in a hidden input field, and saved to database when the form is submitted.

Link to comment
Share on other sites

Why do you need to use the date from the user's computer? The 25th is the 25th, regardless of where they are. Shouldn't you be using the timezone where the events are taking place?
For 2 reasons: 1.I want the current day highlighted, as in ms outlook for example ( i think here i need js date object) 2.The php date function gets the time of the server and not of the user's. But regarding the 2nd point, your answered that i think, i will use the timezone. What about the 1st point? Dsonesuk told me how to pass the data from the js calendar to the db. One last question, is there truly a reason to use a calendar in php since i can do my job with a js calendar.
Link to comment
Share on other sites

I would highlight the current day in the same server timezone, so that it reflects the current date wherever the event is taking place. That's how I've always done it, I set up a calendar to show events at a fitness center, and it uses the date from the server because that is the date at the center. I don't care if someone in Saudi Arabia logs on to the site and sees a different date, I want the highlighted date to be the current date at the physical business location.

Link to comment
Share on other sites

I don't care if someone in Saudi Arabia logs on to the site and sees a different date, I want the highlighted date to be the current date at the physical business location.
:rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: :rofl: Yes, you are right. You could achieve the highlighting with php? I am asking cause the server will be in US while the "physical business location" in Greece.
Link to comment
Share on other sites

Yeah, the code I linked to above outputs different CSS classes for different days. Every cell in the table has a certain class, "calendar-day", and then it adds additional classes based on which date. So the ones that show up in grey get the additional "calendar-disabled" class, and today's date gets the "calendar-today" class. You can look up the stylesheet on that page to see what the various classes add to the table cells. Note that page doesn't have any Javascript at all. You can also use date_default_timezone_set to set the default timezone of the server, so you can set that to be in Greece. You'll need to set that on every page where you use dates. http://www.php.net/manual/en/function.date-default-timezone-set.php There's a list of timezone names here: http://www.php.net/manual/en/timezones.php

Link to comment
Share on other sites

Concluding: Now that the picture is more complete for what i want to achieve, -PHP calendar or a JS one is better? I can do my job with both of them-but which is better. I want to hear also your opinion justsomeguy.

Link to comment
Share on other sites

I will make a php calendar instead. I will keep though the old js code. And see were it will lead. The final decisions will be made on course. PHP offers more potential, more complex scenarios can be made. I have found some code in the web. If i find a difficulty i will post again-in another topic.

Link to comment
Share on other sites

another advantage to PHP is you have the power of the server doing the processing. Rendering the DOM is strenuous enough, although modern browsers are better equipped these days, but I like to save as little for the browser to do as possible (relatively). For instance, for a site I am working on, I am pulling in albums and products from a friends Esty account and a custom store I am making. All the gathering of the data happens on the server side via async AJAX calls and callback, making the calls to the DB and API requests happen on the server. Once the back end processing is done, the data gets sent back as JSON, which I "eval" with jquery and render to the page. From there, for filtering and sorting, I just javascript and custom quick sort methods, but it's not that bad because the data set is already in memory, and plus the user only sorts or filters when and if they want. That way one data set can be easily manipulated and quickly rendered to one "container" element on the page on the fly. It just kind of helps to breakdown what you need to do, and where/when the best place for it to happen is.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...