This topic is locked

PHP Code That Works Fails in page_events.php

10/10/2008 7:59:47 PM
PHPRunner General questions
R
randall author

I'm trying to add 1 week to a date as a Before Record Added event. This code works when I save it in a page called date.php:[codebox]$nextweek = mktime(0, 0, 0, date("m"), date("d")+7, date("Y"));

echo "One week from today will be ".date("m/d/Y", $nextweek).".</br>";[/codebox]
But, it fails in tablename_events.php.

[codebox]$values["call_back_date"] = mktime(0, 0, 0, date("m"), date("d")+7, date("Y"));[/codebox]

It returns the number of seconds instead of a good date. How should I fix it?

Sergey Kornilov admin 10/10/2008

According to PHP manual mktime does return number of seconds between January 1 1970 00:00:00 GMT and the time specified.
http://www.php.net/mktime
You need to convert to proper date format (which you do in first example using date() function. Correct database date format is yyyy-mm-dd.