tanveer Posted February 8, 2007 Share Posted February 8, 2007 Hi all: How to add the time with the user inputted date as the data type is timestamp? As the user will be typing the date and I want to add the time part also with it for making it unique so that later I can delete that record based on that. thanks in advance. Link to comment https://forums.phpfreaks.com/topic/37576-add-current-time-with-date-in-timestamp/ Share on other sites More sharing options...
KrisNz Posted February 8, 2007 Share Posted February 8, 2007 you could use strtotime() on their input but not reliably. Rather than have the user type a date in, Id recommend giving the user three select boxes for day, month and year respectively. That will give you a lot more control over the input. Then to make a timestamp you could use for example //you should validate that the date they've posted is valid, e.g not 30 february, though mktime will work that out as 1 march i think $db_timestamp = mktime(12,0,0,$_POST['month'],$_POST['day'],$_POST['year']); //assuming of course those posted values are integers. Link to comment https://forums.phpfreaks.com/topic/37576-add-current-time-with-date-in-timestamp/#findComment-179703 Share on other sites More sharing options...
tanveer Posted February 9, 2007 Author Share Posted February 9, 2007 thanks. That will do. Link to comment https://forums.phpfreaks.com/topic/37576-add-current-time-with-date-in-timestamp/#findComment-180598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.