Time stamp for database entries?

Time stamp for database entries?

by Dayle Hall -
Number of replies: 8
Hello, does anybody know if it's possible to get a time-stamp to be recorded and then accessed in single and list views on when a database entry was submitted?

I know there is a 'date' field but I'd like the time-stamp to be un-editable by the submitter.
Average of ratings: -
In reply to Dayle Hall

Re: Time stamp for database entries?

by Mark Drechsler -
I'd love to hear an answer to this one too if anyone has done something similar!
In reply to Dayle Hall

Re: Time stamp for database entries?

by Rowan Chakoumakos -
Hello Dayle,

When I working on creating a document sharing database preset, I came upon the same issue.

I have requested this feature in the tracker: MDL-13191

Here is one work around:
1. Create a Date field
2. Go to the add template
3. Disable Editor (button on the left, gray)
4. Change the following code:

<tr>
<td valign="top" align="right">Date Submitted:
</td>
<td>Date Submitted
</td>
</tr>

To this:
<tr style="display:none;">
<td valign="top" align="right">Date Submitted:
</td>
<td>Date Submitted
</td>
</tr>


This edit will make the date submitted field disappear on the add entry. It uses CSS to hide the field. Since the date field defaults to the day and is only hidden, it will be submitted with the date of submission.

Note:
This work around is not perfect because if your students are tech savvy they could either disable CSS or use FireBug to edit the CSS.

Hope this helps,
Rowan
In reply to Rowan Chakoumakos

Re: Time stamp for database entries?

by Dayle Hall -
Hi Rowan,

Thanks for the date field workaround, I have put it to use smile

Look forward to a better solution with time stamp in the future.

Cheers,
Dayle
In reply to Rowan Chakoumakos

Re: Time stamp for database entries?

by Rosario Carcò -

Hi Dayle, Hi Rowan,

Is there also a Hack to format the displaying of the Date field in the database templates, e.g. instead of 28 February 2008 -> 28.02.2008

Thanks a lot, Rosario

In reply to Rosario Carcò

Re: Time stamp for database entries?

by Rosario Carcò -

Hi, here is my solution, to display date-fields in the desired format:

  • copy/paste the javascript function in the attachment into the javascript Tab of the template
  • call this function with "DATE" placeholder as parameter where you want your date to be printed in your template

Where your template has:

    <tr>
      <td valign="top" align="left">Date
      </td>
      <td align="left">Date
      </td>
    </tr>

Replace it with your call and the correct script language tag:

<script.... "javascript">
<!--
  document.write(getMyDate("Date"));
-->
</script>

Any hints and comments are still appreciated, Rosario

In reply to Rosario Carcò

Re: Time stamp for database entries?

by David Bogner -
Picture of Core developers Picture of Plugin developers
Hi Rosaria,

thanks for the script. As I'm austrian it might be helpful in the future.

Best luck for your projects!
David
In reply to Rosario Carcò

Re: Time stamp for database entries?

by Andy Hediger -
Ciao Rosario wink

Thanks a lot for this code ! there is one issue though, I used

<script type="text/javascript">
<!--
document.write(getMyDate("Date Submitted"));
-->
</script>

and your javascript code
but the date spelled out

22..02.2010

and I had to change the last line of your code like :

return (" " + day + "" + month + "." + year);

it does work alright now but I cannot explain this doubling of the "day point"
can you explain this ?

mit herzlichem Gruss
Andy