Re: [PHP] date and time conversion
babu wrote: Hi, how to convert DD.MM.YYand HH:MM:SS into mysql date( '-MM-DD' ) and time format. I think the time is same as HH:MM:SS. [EMAIL PROTECTED] ~ $ php -r 'echo date("Y-m-d",strtotime(str_replace(".","/","12.12.05")))."\n";' 2005-12-12 Hope that helps :) See http://php.net/date http://php.net/strtotime http://php.net/mktime For more information -- Burhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date and time
DIFF FanneHH wrote: I have this date in timestamp format: $a= 20040810114155; I want to add 7 days to this date. How can i do that? echo date('YmdHis',mktime(substr($a,8,2),substr($a,10,2),substr($a,12,2),substr($a,4,2),substr($a,6,2)+7,substr($a,0,4))); Looks like a MySQL timestamp. If so, you can use SELECT yourcolumn + INTERVAL 7 DAY FROM yourtable ... in your query. -- John Holmes php|architect - The magazine for PHP professionals - http://www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date and time problem
echo date ("l dS of F Y h:i:s A"); However, I need to add 12 hrs to this date befor displaying on the webpage. Can someone please help me to modify the above code? $t = time() + (12 * 60 * 60); echo date ("l dS of F Y h:i:s A", $t); Larry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date and time problem
Hi, Monday, February 3, 2003, 11:10:36 AM, you wrote: DLM> Hello friends. DLM> The follwing code displays the date on my webpage : DLM> echo date ("l dS of F Y h:i:s A"); DLM> However, I need to add 12 hrs to this date befor displaying on the webpage. Can someone please help me to modify the above code? DLM> Thanks DLM> Denis use strtotime to get the timestamp for date like this echo date ("l dS of F Y h:i:s A", strtotime('+12 hours')); If this is to compensate for a timezone difference you could also set the timezone at the top of the page, for example putenv('TZ=Australia/Brisbane'); Then date by itself will give the desired result -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date and time functions
> I am on the East Coast of Australia. I'm in central Queensland... > Do you know if by default if the date/time display will > display only East coast Australia time, or will display > from the user's time zone? eg Will USA users see the > Australian time or their own time? Would this cause a issue > with timestamping an order when it comes to writing to a > mySQL database? I presume we're talking about php date/time stuff here? In that case, php gets it's date/time from the server it is running on. If your server is on the east coast of Australia then you'll have local time for east coast of Aust. One way to deal with this would be to take everything back to GMT/UTC/Z and use that instead. Then all you need to do is add an appropriate adjustment to get local time where ever the browser is - of course, you may not easily be able to figure that out so it's not necessarily a perfect solution. In the end, the solution will depend on your requirements. What are you using a timestamp for? If it's purely as a reference point in database queries (i.e. all changes in the past two days, or 10 mins) then it probably doesn't matter all that much. Your database will be updated from your server and your server has a consistent internal time. If your application is date dependant in an absolute way then it becomes a little harder I guess. Although, you'd also ask yourself how relevant it becomes to someone in a vastly different time zone - i.e. if you're doing a local event calendar (which just happens to be one of the things I'm doing right now) then the fact that an event might be happening right now instead of this time tomorrow (from the perspective of someone on the other side of the world and their time zone) is largely immaterial - they aren't going to get there anyway. Perhaps the simplest approach to that is to include a time/date reference. If you're going to include date information let the browser know the context. So, you advertise the next 'xxx' event will be at 3PM 17 May and tell them that it's 10:30AM on 17 May right now. Leave any relevant math up to them. > Can someone suggest a script that may give me the option to > offer both time zones to the user? You could probably do something in javascript (being client-side it knows the time in the browsers' location) to work out equivalencies and conversions if you like. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date and time functions
On Fri, 17 May 2002, DC wrote: > I am on the East Coast of Australia. > > Do you know if by default if the date/time display will display only > East coast Australia time, or will display from the user's time zone? eg > Will USA users see the Australian time or their own time? Would this > cause a issue with timestamping an order when it comes to writing to a > mySQL database? It'll always use the server's time zone unless you explicitly tell it otherwise. > Can someone suggest a script that may give me the option to offer both time > zones to the user? Best is to store times in your server's native time zone, then ask users for their preferred time zone and recalculate times as you display them. That way all users can be accommodated with the same set of data. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date and Time
What version of PHP, OS, web server, etc are you running? Is that the exact code you used? Did you try it in a file all by itself and did it return the same result? ---John Holmes... > -Original Message- > From: baldey_uk [mailto:[EMAIL PROTECTED]] > Sent: Sunday, April 28, 2002 6:22 PM > To: Php-General > Subject: [PHP] Date and Time > > Hi all, > > Anyone know any reason that the date function would return 2am in the > morning as 102 if i use it in the following manner? > > $time=date("H:i:s"); > print $time; > > > this outputs 102:14:51 instead of 02:14:51, anyone know where the 1 comes > from? and why its there? > > > Cheers From > > baldey_uk > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php