You are hereBlogs / willhall's blog / Falsifying Timestamp to give the illusion of historical data

Falsifying Timestamp to give the illusion of historical data


By willhall - Posted on 09 October 2009

I have been looking at a way of inputting content into drupal but falsifying the timestamp to show it as content created years ago. Currently I am in the process of migrating a number of static sites to drupal and as such have to manually copy and paste some of the content across. This then gives timestamps and revisions as new, despite the data being old (between 1-5 years).

I wrote this as a simple way of changing timestamps, obviously not for general use, but it does hack the nodes to pretend its old data:

<?php
mysql_connect('localhost', 'user', 'password') or die('Cannot connect to MySql');
mysql_select_db('database') or die('Cannot connect to database');

$sql = 'select * from node';
$query = mysql_query($sql);

$unixTimestamp = 1230800640; // the oldest peice of data as a unix timestamp
$increment = 1012745; //could be replace by a rand() basically worked out by dividing the time by the number of content

while($result = mysql_fetch_assoc($query)){

$updateNode = "UPDATE node SET created = $unixTimestamp, changed = $unixTimestamp WHERE nid =".$result['nid'];
$updateNodeRevisions = "UPDATE node_revisions SET timestamp = $unixTimestamp WHERE nid =".$result['nid'];

echo 'Completed: '.$updateNode.'';
echo 'Completed: '.$updateNodeRevisions.'';

mysql_query($updateNode);
mysql_query($updateNodeRevisions);

$unixTimestamp = $unixTimestamp + $increment;
}

If anyone has done much of this before or has a better way they think I should be doing it then please let me know.

@willhallonline

  • exasperated at poor connections, may remove and reinstall everything! 10 hours 53 min ago
  • Government sticking to IE6 http://bit.ly/ceMrg9 "more cost effective in many cases to continue to use IE6" (what?!) 13 hours 20 min ago
  • still the mail server continues to frustrate 13 hours 27 min ago
  • feeling positive today, gonna destroy this damned mail server 18 hours 35 min ago
  • where are the open source business analysts who can help out with the actual running of companies, not just make a website for them 18 hours 35 min ago