How do I create a variable to check last time hook_cron() implemented from a custom module was ran? We have a custom module for which we need to run on a daily basis. I am not sure  it is working, as I am unable to store the time correctly. 

Does the following code allow me to create a variable, and use it to store the last time cron ran?

function mymodule_cron() {
  if (variable_get('mymodule_last_run', 0) &lt;= strtotime('-1 day')) {
    // Omissis.
    variable_set('mymodule_last_run', time());
  }
}

function mymodule_info($options) {
  $variable['mymodule_last_run'] = array(
    'title' =&gt; t('Last Run', array(), $options),
    'type' =&gt; 'datetime',
    'default' =&gt; t(time(), array(), $options),
  );
}
You are implementing the wrong hook. What you are trying to implement is hook_variable_info(), used from the Variable module. Hook name apart, that hook implementation seems correct.

Instead of using variable_set(), you should use variable_set_value(). The equivalent of variable_get() is variable_get_value().

See the project page for more information about how to use the module API,  Variable API for a list of available functions, and variable.api.php for a list of hooks used from the Variable module.

The code you want to use should be similar to the following one.

function mymodule_cron() {
  if (variable_get_value('mymodule_last_run') &lt;= strtotime('-1 day')) {
    // Omissis.
    variable_set_value('mymodule_last_run', REQUEST_TIME);
  }
}

function mymodule_variable_info($options) {
  $variable['mymodule_last_run'] = array(
    'title' =&gt; t('Last Run', array(), $options),
    'type' =&gt; 'datetime',
    'default' =&gt; 0,
  );
}


Notice that variable_get_value() doesn't need the default value, since it gets it from the hook_variable_info() implementation done from your module. If you need to use a different default, you call the function as variable_get_value('mymodule_last_run', array('default' =&gt; REQUEST_TIME).

As for your original code, you don't call t() as t(time(), array(), $options) because:


The first argument of t() must be a literal string, not the value returned from a function
time() returns an integer; even if it would be casted to a string, t() doesn't change an integer in any way, for example returning '1,000' when receiving 1000 as first argument.


If the Variable module is expecting a string (e.g. '19700318T19:00') as default value for a variable of type datetime, you need to use a different function.