son Posted October 18, 2011 Share Posted October 18, 2011 I display in form a timestamp as: $dateEcho=date("d.m.Y, G:i", $dateEcho); This field can be updated. To convert the date back into timestamp format I use: $dateEcho=mktime($dateEcho); Changing the displayed date always enters the current timestamp plus one hour... How can I enter the timestamp as displayed in input dateEcho? Son Link to comment Share on other sites More sharing options...
Ingolme Posted October 18, 2011 Share Posted October 18, 2011 Look at the mktime() documentation. The parameters need to be mktime(hour, minute, second, month, day, year). You should keep $dateEcho as a timestamp form, and set the date to be printed in another variable. If you really need it, there's the strtotime() function Link to comment Share on other sites More sharing options...
son Posted October 18, 2011 Author Share Posted October 18, 2011 I used now strtotime() and it seems to do the trick fine. When you said 'You should keep $dateEcho as a timestamp form, and set the date to be printed in another variable.' I cannot see how I could achieve this. The timestamp value is coming from db, converted for user conveniece to date format to be displayed in form input field which can be updated by user. So, the value coming from the form field will be in any case in date format. Is this what you mean? And is there a problem with using strtotime? Many thanks,Son Link to comment Share on other sites More sharing options...
Ingolme Posted October 18, 2011 Share Posted October 18, 2011 No, there isn't a problem with strtotime(), just be sure that the input date is in one of the recognized date formats it allows. You can see those in the documentation. Link to comment Share on other sites More sharing options...
son Posted October 19, 2011 Author Share Posted October 19, 2011 Thanks. Date is in good format and works well:-) Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.