Solving a Drupal Timestamp Problem

This is a post that will not be of interest to 99.9% of the people who see it, but since I’ve spent the last two months or so trying to remember how I solved the problem the first time I faced it, I feel the need to put it down in writing.

The Problem (Part 1): Drupal’s webform module makes it possible for submitters to edit their previous submissions, but while it tracks when the original submission is made, it does not do so for subsequent edits.

The Solution (Part 1): I created a hidden field [‘edit-submitted-timestamp’] in the form, and added a bit of javascript in a block at the bottom of the form [document.getElementById(‘edit-submitted-timestamp’).value = Date()] so that every time the form was edited, the browser would insert the current date in the hidden field.

The Problem (Part 2): Just using “Date” meant that browsers would insert the date in an unwieldy format (usually something along the lines of “Wed, Mar 19 2014 09:24 GMT -0500 (Central Daylight Time)”), and worse, did so inconsistently (since the format seems to depend on the user’s browser, operating system, etc.)

The Solution (Part 2): A bit of tweaking to the javascript was necessary to ensure a consistent and sortable date was being inserted. The final script I wound up with is:

<script>
function addDate(){
date = new Date();
var month = date.getMonth()+1;
var day = date.getDate();
var year = date.getFullYear();
var hours = date.getHours();
var minutes = date.getMinutes();

document.getElementById(‘edit-submitted-timestamp’).value = year + ‘-‘ + month + ‘-‘ + day + ‘;’ + hours + ‘:’ + minutes;

}
window.onload = addDate;
</script>

UPDATE: This turned out not to be the best format for sortability (no padding 0s for numbers under 9), so here is the updated Javascript:

<script>
function addDate(){
date = new Date();
var month = date.getMonth()+1
if(month <= 9)
    month = ‘0’+month;
var day = date.getDate();
if(day <= 9)
    day = ‘0’+day;
var year = date.getFullYear();
var hours = date.getHours();
if(hours <= 9)
    hours = ‘0’+hours;
var minutes = date.getMinutes();
if(minutes<= 9)
    hours = ‘0’+minutes;

document.getElementById(‘edit-submitted-timestamp’).value = year + ‘-‘ + month + ‘-‘ + day + ‘;’ + hours + ‘:’ + minutes;

}
window.onload = addDate;
</script>

Higher Ed Web vs. the Academy

This month marks eight years since I made the decision to withdraw from a PhD program at the University of Chicago Divinity School and become a full-time web professional. It was a difficult decision to make, given the five years, the lord knows how much money, and the amount of my own identity I had already invested in the idea that I was one day going to be a religion professor. As the anniversary rolls around, I’m still sure I made the right choice; not the least of the reasons for this has to do with an observation I made recently about the nature of life within the respective spheres of the academy and the world of the higher ed web.

I recently spoke on a panel about potential non-traditional career paths with a Div School master’s degree. The students I met were all very nice, and of course very smart; but there was a certain look in many of their eyes, a demeanor that I recognized all too well from own time there. It was a wary cautiousness, bordering on defensiveness, that immediately brought me back to how it felt to wander through academic conference rooms where a cloud of insecurity seemed to hover in the air, a general fear that a single well-placed question might reveal one as a fraud who had only been admitted to this world of frighteningly intelligent people through some sort of clerical error.

I thought about how different that feeling was than the time I’ve spent at higher ed web conferences, where a strong sense of community and “we’re all in this together” camaraderie always seems to reign, and where being able to play a good hand of Cards against Humanity or belt out a karaoke song without fear tend to be more important than maintaining any sense of professional decorum. I think this difference is due in part to the respective media within which academics and webbies live. The academic process, in my experience, seems inherently individualistic, and thus isolating; from the admissions process to the dissertation defense to the job hunt and beyond, the experience is a largely adversarial one, with a single individual’s work being held up for scrutiny and judgement by more senior authorities or one’s own peers.

Web professionals, on the other hand, must quickly accept that our field changes so quickly—total paradigm shifts can occur within months, rather than a generation—that we are dependent upon our community for help. Very few of us can possibly know everything we need to know in order to do our jobs well, and most of us either are lucky enough to either work in teams or are constantly asking colleagues for, say, a bit of javascript help or some quick design feedback for our latest project. Building the web, I would argue, is inherently collaborative, more like putting on a play than writing a book, and thus cultivates a sense of the need to share, to help one’s peers, knowing that you yourself will almost certainly need their help in the very near future.

To be clear, I’m in no way claiming that there is not a sense of community among academics in a given field or a given graduate school cohort; I know that many of my friends who have remained in academia gain much from their support networks within the academy. But I would argue that the structural differences I’ve just described make that sort of community far more difficult to create and maintain within academia. If higher education is interested in improving the quality of life of its budding professionals, it could do worse than taking a page from the folks who build its websites.