Jump to content
iEnno

Display and calculate with current date and time

Recommended Posts

I created a workflow to display the current date and time in a configurable format.

Pressing enter will copy to clipboard.

 

screenshot_date.png

 

You can also add and subtract time. Examples:

  • date 3w: today + 3 weeks
  • date -2y: today - 2 years
  • date 2m -5d: today + 2 months - 5 days

View GitHub for more details.

 

Direct Download.

Edited by iEnno

Share this post


Link to post

Doesn´t work for me:

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in - on line 2 April 1, 2013 – 14:39

 

Do you have any ideas?

 

I found this workflow over your (german) RSS feed.

Nice one, i like it! :)

 

Domenic

Share this post


Link to post

Very nice idea, but wouldn’t it be much simpler (not to mention probably both faster and less prone to PHP warnings) to use the POSIX date utility that ships with OS X?

Share this post


Link to post

All these PHP error kind of bug me, because I thought they are due to wrong php.ini settings when using PHP >=5.3. Will fix that as soon as I find a minute.

 

Very nice idea, but wouldn’t it be much simpler (not to mention probably both faster and less prone to PHP warnings) to use the POSIX date utility that ships with OS X?

Thanks for the suggestion. Obviously didn't know about it. Will have a look into.

Share this post


Link to post

Whatever PHP error it gives just export that timezone in the 'date' script filter, just place above the one line of code... like so:

export TZ="America/New_York"
ruby date.rb "{query}"

Thank you!

Now it´s working!

Share this post


Link to post

I built a new version using kopischke's suggestion which increases speed dramatically.

You should be able to update it via alleyoop. If that won't work, please report back and use the link in the first post of this topic ("Direct Download").

From now on in order to configure the date output you have to use strftime syntax. The Workflow should migrate your current setting automatically. Please report back if there are any problems.

Once again: thanks for all suggestions and error reports.

Edit: the timezone fixes shouldn't be necessary anymore.

Edited by iEnno

Share this post


Link to post

I kinda wanna  make a hotkey that directly shows the date and time in large type, but my attempts end in the script itself being shown – could somebody help me out here? Thanks, much appreciated :)

Share this post


Link to post

Any chance to combine the same date format customization options there?

 

1. Open the Workflow in Alfred Preferences

2. Double-Click the "Run Script" action

3. Add your format, i.e. date +"%B %d, %Y"

 

The +-sign says "here comes a format", double quotes wrap it and the actual characters with the %-sign appended have a specific meaning.

The possible characters for the format scan be looked up on http://strfti.me/,

Edited by iEnno

Share this post


Link to post

1. Open the Workflow in Alfred Preferences

2. Double-Click the "Run Script" action

3. Add your format, i.e. date +"%B %d, %Y"

 

The +-sign says "here comes a format", double quotes wrap it and the actual characters with the %-sign appended have a specific meaning.

The possible characters for the format scan be looked up on http://strfti.me/,

Thanks a million :)

Share this post


Link to post

Is there any way to make this workflow calculate from a future date/time?  I'd like to be able to enter some date/time in the future and then add/subtract time from that date.  Any way to do this?  Thanks!

Share this post


Link to post

Is there any way to make this workflow calculate from a future date/time?  I'd like to be able to enter some date/time in the future and then add/subtract time from that date.  Any way to do this?  Thanks!

 

Currently there is no way to achieve what you want, but it would surely be useful though. I will try to make some time to implement it, but don't expect it anytime soon. I will let you know when it's ready.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...