Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Sorry for the lame question

How many minutes have passed since the Unix Epoch ? It should be January 1, 1970 ?

Let's say approximately until 1 Jan 2011... 5 865 696 000 minutes ?

share|improve this question

3 Answers 3

up vote 8 down vote accepted
#!/bin/bash

# Minutes since Epoch until now:
((minutes=$(date +%s)/60))

# Minutes since Epoch until Jan 1 2011:
((minutes=$(date -d 'Jan 1 2011' +%s)/60))
share|improve this answer
1  
The %s in date +%s is a GNU extension. Other implementations typically allow the same format strings as in strftime(3), which mostly don't have %s. And WHY do everybody assume bash availability? –  MattBianco Mar 31 '11 at 6:41
    
Does this take leap seconds into account? –  mattdm Mar 31 '11 at 15:51
1  
@mattdm> From info date... %s "...Leap seconds are not counted unless leap second support is available." ... %S "second ('00'...60'). This may be '60' if leap seconds are supported." ... I can only assume that it would include those seconds in a total of 'seconds-since-epoch' when the support is available. –  Peter.O Mar 31 '11 at 16:20
    
Cool, thanks. GNU thinks of everything. :) –  mattdm Mar 31 '11 at 17:02
1  
@mattbianco 1) i didn't necessarily "assume" bash availability. I provided my solution using bash. It doesn't have to be accepted by @patrick as the answer and you can provide your own solution. 2) When discussing Linux, it's almost certain that bash is available. I'd put my guess at about 99.9% likely given any random selection of Linux installations. 3) I use OSX and %s is available in BSD's date even though, in general, it's a significantly command than GNU's date. –  nix Apr 1 '11 at 14:53

If you've got Python installed then you can run this:

python -c "import time; print time.time() / 60"
share|improve this answer

You can check the online version of Unix Epoch: Epoch Converter. You can get the current Epoch value and also convert time back to epoch

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.