Page 1 of 1

[SOLVED] How to get a date()?

Posted: Thu Oct 06, 2005 10:13 am
by $var
G'day (Yar),

I have a member database that runs on membership.

I'm trying to insert the date ($today) automatically in 'active',
Add 1 Year ($nextyear), and insert that value into 'expire'.

These are the different ways I've tried it, and nothing is passing...

Code: Select all

<?php
$today = date("F j, Y, g:i a"); 
$nextyear = date("F j, Y+1, g:i a"); 
?>
or

Code: Select all

<?php
$today  = mktime(0, 0, 0, date("m")  , date("d"), date("Y"));
$nextyear  = mktime(0, 0, 0, date("m"),  date("d"),  date("Y")+1);
?>
into

Code: Select all

<input class="text" name="active" type="hidden" id="active" value="<? $today ?>">
<input class="text" name="expire" type="hidden" id="expire" value="<? $nextyear ?>">

Posted: Thu Oct 06, 2005 10:18 am
by n00b Saibot
$var wrote:How to get a date
ermmm.... for this you will have to contact a dating company, or visit a dating site or try it out yourself :lol:

Well, seriously, why don't you use mysql built-in date functions NOW() & ADDDATE() to do that stuff :?:

Posted: Thu Oct 06, 2005 10:25 am
by feyd
as a side note, the last php code block $var posted will not write anything into the output string for the values.. ;)

Posted: Thu Oct 06, 2005 10:38 am
by $var
posted will not write anything into the output string for the values
wait, what won't it do?
i mean, i have found that nothing is passing, but is that just what you mean?

Posted: Thu Oct 06, 2005 10:42 am
by feyd
that's right.. nothing will pass.. the values will be blank on the page.

Code: Select all

<input class="text" name="active" type="hidden" id="active" value="<?php echo $today; ?>">

Posted: Thu Oct 06, 2005 10:43 am
by n00b Saibot
feyd wrote:as a side note, the last php code block $var posted will not write anything into the output string for the values.. ;)
simply overlooked that :roll:

Posted: Thu Oct 06, 2005 10:56 am
by $var
because they are hidden fields?
or because they are improper syntax?

Posted: Thu Oct 06, 2005 11:04 am
by n00b Saibot
$var wrote:because they are hidden fields?
or because they are improper syntax?
because there is no echo or '='. without echo it outputs nothing that's why the blank output

Posted: Thu Oct 06, 2005 11:06 am
by $var
so if i put <?php echo=('$today'); ?> it would pass something?

Posted: Thu Oct 06, 2005 11:16 am
by n00b Saibot
$var wrote:so if i put <?php echo=('$today'); ?> it would pass something?
either

Code: Select all

<?php echo $today; ?>
or

Code: Select all

<?php =('$today') ?>
will work

Posted: Thu Oct 06, 2005 11:43 am
by feyd
the second is a parse error (and will display the string $today, not the value inside ;)).. and the idea:

Code: Select all

<?= $somevar; ?>
only works when short tags are on. Since it's optional, it's recommended to always use the long form:

Code: Select all

<?php echo $somevar; ?>

Posted: Fri Oct 07, 2005 12:42 am
by n00b Saibot
egad 8O what is happening to me :? maybe that was drowsiness after a long day :(