Jump to content

Timestamp Conversion Issue


son

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...