BluwAngel Posted March 30, 2012 Share Posted March 30, 2012 im wondering is there any easy way to echo server time and local time... without converting them from unix to timestamp i have found thi code, but i cant tell is it server or local echo date("H:i" ,time()); Quote Link to comment https://forums.phpfreaks.com/topic/260028-server-and-local-time/ Share on other sites More sharing options...
jon4433 Posted March 30, 2012 Share Posted March 30, 2012 I have a Javascript script which gets your local time. Not sure how to do it in php. But this might help. http://php.net/manual/en/function.getdate.php Quote Link to comment https://forums.phpfreaks.com/topic/260028-server-and-local-time/#findComment-1332833 Share on other sites More sharing options...
jbonnett Posted March 30, 2012 Share Posted March 30, 2012 This should help PHP time() and date() function <?php $b = time (); echo date("m/d/y",$b) . "<br>"; echo date("D, F jS",$b) . "<br>"; echo date("l, F jS Y",$b) . "<br>"; echo date("g:i A",$b) . "<br>"; echo date("r",$b) . "<br>"; echo date("g:i:s A D, F jS Y",$b) . "<br>"; ?> DAYS d - day of the month 2 digits (01-31) j - day of the month (1-31) D - 3 letter day (Mon - Sun) l - full name of day (Monday - Sunday) N - 1=Monday, 2=Tuesday, etc (1-7) S - suffix for date (st, nd, rd) w - 0=Sunday, 1=Monday (0-6) z - day of the year (1=365) WEEK W - week of the year (1-52) MONTH F - Full name of month (January - December) m - 2 digit month number (01-12) n - month number (1-12) M - 3 letter month (Jan - Dec) t - Days in the month (28-31) YEAR L - leap year (0 no, 1 yes) o - ISO-8601 year number (Ex. 1979, 2006) Y - four digit year (Ex. 1979, 2006) y - two digit year (Ex. 79, 06) TIME a - am or pm A - AM or PM B - Swatch Internet time (000 - 999) g - 12 hour (1-12) G - 24 hour c (0-23) h - 2 digit 12 hour (01-12) H - 2 digit 24 hour (00-23) i - 2 digit minutes (00-59) s 0 2 digit seconds (00-59) OTHER e - timezone (Ex: GMT, CST) I - daylight savings (1=yes, 0=no) O - offset GMT (Ex: 0200) Z - offset in seconds (-43200 - 43200) r - full RFC 2822 formatted date Quote Link to comment https://forums.phpfreaks.com/topic/260028-server-and-local-time/#findComment-1332834 Share on other sites More sharing options...
kicken Posted March 30, 2012 Share Posted March 30, 2012 The date and time you get from PHP is going to be the server's time. If you want the clients local time you have two options: 1) Have the user set their timezone and then figure it out based on the server's time. The [m=datetime]DateTime class[/m] makes this pretty easy. 2) Obtain the date/time using Javascript code and it's Date object. Quote Link to comment https://forums.phpfreaks.com/topic/260028-server-and-local-time/#findComment-1332855 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.