Hi i am having problem on how can i calculate the 2 days before on the expected date…for example the expected date is july 25,how can i calculate the 2 days before july 25,because i want to try sending information to my client on before july 25 comes.
It is an interval specification:
The format starts with the letter P, for “period.” Each duration period is represented by an integer value followed by a period designator.
In this case P2D means a “Period of 2 Days”
Yes, this will work too. OP had another thread regarding dates, and I was about to suggest moving to DateTime object, as it is newer and object oriented, allowing for IMO more functionality and cleaner code.
AFAIK, you cannot use PHP to get the time on a client machine.
This is because PHP is a server-side language that is executed before the code ever reaches the client’s system.
To get the client’s time, you can use JavaScript.
I guess it could be done by getting the user’s location from their IP address, and then setting the timezone based on that, but it’s not guaranteed to work as they could be using some kind of proxy or something like that.
Yeah, I thought of that too, but given the IP lookup, coupled with the possibility of the user accessing the site via a proxy, it seemed like a lot of stress to do it this way.
Depending on how crucial the timezone is to his application, I might try to use GeoIp to suggest their timezone to them, allow them to alter it and store it under their account preferences. From here all operations would be stored as UTC-0 and then you can display back to front end user based on their timezone setting.
You can always avoid this just by using UTC-0 as default for everything The only problem left is front end display to the end user, at that point it would just be on them to set their preference.
That would be the way I would go.
Much easier than doing an IP lookup to work out their time zone and gets around the proxy problem, too.
As you say, depends how critical this is to the app in question.