pranshu82202 Posted July 13, 2011 Share Posted July 13, 2011 guyzz i created a column in my mysql database with datatype datetime... Deafult: 0000-00-00 00:00:00 I want to get the time when user logged in his account... But i am not getting the proper php function which i shuld use here.. Can you tell me which php function i shuld use.... Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/ Share on other sites More sharing options...
gristoi Posted July 13, 2011 Share Posted July 13, 2011 INSERT INTO table (datetimeField) values (now()) Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242154 Share on other sites More sharing options...
pranshu82202 Posted July 13, 2011 Author Share Posted July 13, 2011 Thanxx man... Date is working fine but the time it enters is wrong.... My system's clock is showing correct time... Value which the function gives is : 2011-07-13 10:55:20 :confused: :confused: :confused: :confused: Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242155 Share on other sites More sharing options...
gristoi Posted July 13, 2011 Share Posted July 13, 2011 and what time do you think it should be? Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242156 Share on other sites More sharing options...
pranshu82202 Posted July 13, 2011 Author Share Posted July 13, 2011 4:51 PM i.e 16:51:00 Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242157 Share on other sites More sharing options...
gristoi Posted July 13, 2011 Share Posted July 13, 2011 sounds like your server is not in the same timezone as you . Is this your own server? you could try passing in the time on the php side: <?php $now = date('Y-m-d H:i:s', time()) ?> Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242159 Share on other sites More sharing options...
pranshu82202 Posted July 13, 2011 Author Share Posted July 13, 2011 I am hosting the php's on a webserver (dont know whether in my timezone or not )..... Can i have the now() function according to me.... Can i add or subtract something from it ??? Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242160 Share on other sites More sharing options...
gristoi Posted July 13, 2011 Share Posted July 13, 2011 where in the world are you? Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242161 Share on other sites More sharing options...
pranshu82202 Posted July 13, 2011 Author Share Posted July 13, 2011 INDIA ... Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242163 Share on other sites More sharing options...
gristoi Posted July 13, 2011 Share Posted July 13, 2011 <?php // offset diefference between you and the server $offset = 6; $now = date('Y-m-d H:i:s', time()+$offset*60*60) ?> Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242166 Share on other sites More sharing options...
pranshu82202 Posted July 13, 2011 Author Share Posted July 13, 2011 Thanxx gristoi.... It worked successfully ..... :D Quote Link to comment https://forums.phpfreaks.com/topic/241881-datetime/#findComment-1242167 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.