Page 1 of 1

Date and Time

Posted: Mon Apr 02, 2012 9:39 am
by ruiascensao
Hi,

How can I have a text object with data + time?

Thank You,

Best Regards,
Rui

Re: Date and Time

Posted: Tue Apr 03, 2012 12:03 am
by admin
Rui,

You can just use a wider text area and make a JavaScript function to validate it.

http://stackoverflow.com/questions/4460 ... javascript

nuBuilder has no built in format for that.

Steven

Re: Date and Time

Posted: Thu Apr 12, 2012 5:28 pm
by ruiascensao
Hi Steven,

I am using in the form "before open":

Code: Select all

$sql = "SELECT CURDATE() AS date";
$result = nuRunQuery($sql);
$date = db_fetch_object($result);
$date = date("d-M-Y");

$javascript = " function  nuLoadThis() {\n";
$javascript .= " if (document.getElementById('unit_date').value == ''){\n";
$javascript .= " document.getElementById('unit_date').value = '".$date."';\n";
$javascript .= "}}\n";
addJSFunction($javascript);
Result is not correct! I get tomorrows date.

If I use:

Code: Select all

$sql = "SELECT now() AS date";
$result = nuRunQuery($sql);
$date = db_fetch_object($result);
$date = date("d-M-Y H:i:s");

$javascript = " function  nuLoadThis() {\n";
$javascript .= " if (document.getElementById('unit_date').value == ''){\n";
$javascript .= " document.getElementById('unit_date').value = '".$date."';\n";
$javascript .= "}}\n";
addJSFunction($javascript);


... the now() function doesn't work!

Any idea why is not working? I have checked the dates in my systems and are correct.

Thank you!
Best regards,
Rui

Re: Date and Time

Posted: Mon Apr 16, 2012 10:16 am
by MichaelD
Rui,
are you sure you have set the correct timezone (+date) on your MySQL Server?

Re: Date and Time

Posted: Tue Apr 17, 2012 5:51 pm
by ruiascensao
Hi MichaelD,

Yes it is correct:

mysql> SELECT CURDATE() AS date;
+------------+
| date |
+------------+
| 2012-04-17 |
+------------+
1 row in set (0.00 sec)
-----

Any other idea?

Best Regards,
Rui

Re: Date and Time

Posted: Wed Apr 18, 2012 9:35 am
by admin
Rui,

this will give you date and time

Code: Select all


$sql   = "SELECT now() AS date";
$table = nuRunQuery($sql);
$row   = db_fetch_row($table);
$date  = $row[0];

Steven

Re: Date and Time

Posted: Wed Apr 18, 2012 5:57 pm
by ruiascensao
Thank You Steven!
It's working.

Best Regards,
Rui

Re: Date and Time

Posted: Mon Apr 23, 2012 4:26 am
by admin
.