You can set the current time with the currentTime command.
You can query the currentTime command to return the current time in a format controlled by the currentUnit command.
The following commands store the current time in seconds in the $time variable:
// Save the current time unit in a variable
string $timeFormat = `currentUnit -query -time`;
// Set the current time unit to seconds
currentUnit -time sec;
// Store the current time in $time
float $time = `currentTime -q`;
// Restore the original time unit we saved earlier
currentUnit -time $timeFormat;