laPistola Posted October 26, 2008 Share Posted October 26, 2008 Hello All I have a question regarding time value submittion, im creating my own blog/story submittion website and every thing has gone great but polishing up i realised to my emmbarrishment that when users display stories in order of time it don't work. All i was doing was inserting a hidden field with the value of date("H:i d/m/Y") which then got inserted into the MySQL field. I have looked at the built in timestamp etc but i have read that having the time as a value etc '1196732150' but how to i get this to work. I have changed the date MySQL field to BIGINT(30) but after an hour of searching i can't seem to find a way to do this. Thanks for anyhelp. Link to comment https://forums.phpfreaks.com/topic/130164-solved-submitting-time-as-a-value/ Share on other sites More sharing options...
xtopolis Posted October 26, 2008 Share Posted October 26, 2008 I would use a datetime field, which has the format: 2008-10-26 17:48:49 ("Y-m-d H:i:s") You can format off that date easily using mysql DATE_FORMAT() or something in PHP. Also you can order by (thatcolumn) very easily in mysql. Link to comment https://forums.phpfreaks.com/topic/130164-solved-submitting-time-as-a-value/#findComment-675059 Share on other sites More sharing options...
laPistola Posted October 27, 2008 Author Share Posted October 27, 2008 Thank you, this is how i have decidered to do it but using the timestamp field as i require the update to current time attribute just out of pour curistity and a desire to learn how do you still get it to submit the date as a value like '1196732150' ? Link to comment https://forums.phpfreaks.com/topic/130164-solved-submitting-time-as-a-value/#findComment-675885 Share on other sites More sharing options...
Barand Posted October 27, 2008 Share Posted October 27, 2008 2 ways (timecol defined as INT) MySQL INSERT INTO table (timecol) VALUES (UNIX_TIMESTAMP()) PHP $time = time(); INSERT INTO table (timecol) VALUES ($time) Link to comment https://forums.phpfreaks.com/topic/130164-solved-submitting-time-as-a-value/#findComment-675938 Share on other sites More sharing options...
fenway Posted October 27, 2008 Share Posted October 27, 2008 TIMESTAMP have funny time zone issues. Link to comment https://forums.phpfreaks.com/topic/130164-solved-submitting-time-as-a-value/#findComment-675956 Share on other sites More sharing options...
Barand Posted October 27, 2008 Share Posted October 27, 2008 I'd go with a DATETIME type rather than a UNIX_TIMESTAMP. Most date/time functions expect a date/datetime/time type so you have to convert your timestamps to dates first. Link to comment https://forums.phpfreaks.com/topic/130164-solved-submitting-time-as-a-value/#findComment-675967 Share on other sites More sharing options...
fenway Posted October 28, 2008 Share Posted October 28, 2008 I agree... TIMESTAMP is evil... who would want to use a field that won't work after 2039? Link to comment https://forums.phpfreaks.com/topic/130164-solved-submitting-time-as-a-value/#findComment-676584 Share on other sites More sharing options...
laPistola Posted November 14, 2008 Author Share Posted November 14, 2008 Thanks, i better change from timestamp to datetime then Cheers Link to comment https://forums.phpfreaks.com/topic/130164-solved-submitting-time-as-a-value/#findComment-690330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.