This topic is locked

display date and time in list page after a record is added

5/16/2008 10:23:53 PM
PHPRunner General questions
B
bochaka author

I have a table called tablea with a readonly text field called dateandtime.I would like to know how to have the date and time automatically added after a new record is added so that it appears in the list page. the date format would be day month year and then hpurs minutes and secounds.

I thought this might be relativly easy however the more I researched it the more confused i get.

S
swanside 5/17/2008

I have a table called tablea with a readonly text field called dateandtime.I would like to know how to have the date and time automatically added after a new record is added so that it appears in the list page. the date format would be day month year and then hpurs minutes and secounds.

I thought this might be relativly easy however the more I researched it the more confused i get.


In Visual editor, double click on the item you want to display the date and time, in the new box that opens select the Edit as tab and select date, In the default value box enter now()

B
bochaka author 5/17/2008

Hi

That worked well, but it displays the server time which is about 6 hours behind my time zone which is where most of my visitors will post from.Is there a way to add 6 hours to the time or even default to GMT or ut as I believe it is now called.

J
Jane 5/20/2008

Hi,
here is a sample:

date("Y-m-d",strtotime("+6 hour"))


More info here:

http://php.net/manual/en/function.date.php

http://php.net/manual/en/function.strtotime.php

B
bochaka author 5/21/2008

H Jane

It kinda worked maybe i did something wrong.I replaced the now() with the above code, it displays the date ok but the time is 00:00:00

J
Jane 5/22/2008

Hi,
try to use this code:

date("Y-m-d h:i:s",strtotime("+6 hour"))



More info here:

http://php.net/manual/en/function.date.php

B
bochaka author 5/22/2008

Works Fine, Many Thanks.

B
bochaka author 5/22/2008

Now for the hard bit, I hope you can help me again with this.

The date is now included in the added record and next I want to make sure that the logged in user can add no further records or edit the record for 90 days since his last added record. I have no idea where to start with this.

J
Jane 5/23/2008

Hi,
edit your add and edit links on the list page in HTML mode on the Visual Editor tab.

Here is a sample:

{if $check_date}

<a href=...>...</a>

{/if}


Then check entered date in the List page: Before display event and assign correct value to $check_date variables:

$smarty->assign("check_date",1);

B
bochaka author 5/23/2008

do i need to replace the " $check_date" bit with some other code or enter it as is, and where do I specify 90 days,

My table name is _litters and the time and date field is called timedate, all litters have a litterid number which is the primary key in this table can you tell me the full code I need to achiever this,

the login user is a primary key called _breedernumber in a table called _breeder his name is automatically added to the add page using $_SESSION["UserID"] IN THE VISUAL EDITOR and this is read only.

The code to create this is at present beyond my abilities, so any help is appreciated.

J
Jane 5/26/2008

Hi,
please publish your project on the Demo Account and send a URL to your pages to support@xlinesoft.com.

B
bochaka author 5/26/2008

Hi Jane

I have uploaded as you requested, while your looking at it could you also examine the other issue I have posted here regarding the displaying of some firlds only.

Regards.