sivanath.nagendran Posted December 4, 2006 Share Posted December 4, 2006 Hi I am newbie to PHP. Can anyone pls tell me How to Print the [b]Current Local System Time[/b] in my Web page. is this possible?Thanks for helpBy Sivanath.N Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/ Share on other sites More sharing options...
fert Posted December 4, 2006 Share Posted December 4, 2006 you should use the date() function Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-134686 Share on other sites More sharing options...
JasonLewis Posted December 4, 2006 Share Posted December 4, 2006 you can also use time() to get it but it would be a LOT quicker to just use the date(), as fert said. :) Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-134689 Share on other sites More sharing options...
Psycho Posted December 4, 2006 Share Posted December 4, 2006 I think the OP may be referring to the user's current local time. If that is the case, then you would need to do that with client side javascript. The PHP time functions are for the server's current time. Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-134691 Share on other sites More sharing options...
JasonLewis Posted December 4, 2006 Share Posted December 4, 2006 you can get the users timezone, if they are required to register and work out their local time. Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-134744 Share on other sites More sharing options...
sivanath.nagendran Posted December 4, 2006 Author Share Posted December 4, 2006 [b]Can anyone please show me the code for how to print the system time in web page?[/b]Thank you so much for your helpBySivanath.N Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135016 Share on other sites More sharing options...
craygo Posted December 4, 2006 Share Posted December 4, 2006 Do you want the time of the user that is viewing the page or the local time of the server???Ray Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135017 Share on other sites More sharing options...
Psycho Posted December 4, 2006 Share Posted December 4, 2006 Printing the server's time in PHP:echo date('h:i A'); //something like 12:23 PMPrinting the user's time in javascript:timeStamp = new Date();var hours = timeStamp.getHours();meridiem = (hours < 12) ? ' AM' : ' PM';hours = (Hours > 12) ? hours -= 12 : hours;var mins = timeStamp.getMinutes();mins = (mins<10) ? '0'+mins : mins;document.write(hours + ':' + mins + meridiem'); Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135032 Share on other sites More sharing options...
sivanath.nagendran Posted December 4, 2006 Author Share Posted December 4, 2006 If you dont mine, pls Show me the relevant Code. Then also Is it possible for Display the Time like Railway time (Second by second automatically increased)Thank you Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135035 Share on other sites More sharing options...
Psycho Posted December 4, 2006 Share Posted December 4, 2006 I did show you the code.What do you mean by "Railway time (Second by second automatically increased)"? If you mean you want to have the time actually change on the web page in real time, then that is javascript. There are many free scripts available - just do a search for "javascript clock" or something to that effect. Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135067 Share on other sites More sharing options...
sivanath.nagendran Posted December 4, 2006 Author Share Posted December 4, 2006 Sorry But I need code without using any scripting language like java script. Using only php I need the code for that? I tried some thing in my system time is 14.44 but It shows in web page 20.05 etc.. using PHP language? Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135070 Share on other sites More sharing options...
Psycho Posted December 4, 2006 Share Posted December 4, 2006 As already stated in this thread - there is no way for PHP to know the user's local time. PHP can only retrieve the time of the server it is running on. To do what you are asking you need to implement some functionality so they can set their timezone and have the system save that somewhere, such as a database. Then you could show the user their local time by retrieving the servers time and offsetting it based upon the user's timezone. Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135116 Share on other sites More sharing options...
sivanath.nagendran Posted December 5, 2006 Author Share Posted December 5, 2006 Hi Ya it's correct. I could store the current time into Database, whenever the user should press Submit button.Thanks for your advice.Thank you very muchBySivanath.N Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135439 Share on other sites More sharing options...
Psycho Posted December 5, 2006 Share Posted December 5, 2006 [quote author=sivanath.nagendran link=topic=117263.msg479041#msg479041 date=1165326109]I could store the current time into Database, whenever the user should press Submit button.[/quote]Just so we are clear, you can't store the current time for the user unless you use javascript to populate the field to be submitted or you specificly ask the user for their timezone. Link to comment https://forums.phpfreaks.com/topic/29367-how-to-print-current-local-system-time-in-web-page/#findComment-135474 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.