Output Friendly Date & Time In Build Steps

Hi - does anyone know how to output a human readable date & time during the build step? We want to pass the build date & time string to slack and other steps where we can keep a record of when the build was created, but the $BITRISE_BUILD_TRIGGER_TIMESTAMP only gives out unix timestamp. Any insight would be appreciated!

1 Like

Hi @chrisfullscreen,

Do you need the time of the trigger? Or is the time of when the build starts to run enough?

If it is enough just drop in the Generate timestamps step which can generate a more human readable timestamp.

Hi, a little bit late to the game but do you know how we could further format the $ISO_DATETIME variable thatโ€™s generated by the Generate Timestamps step into something even more human readable?

Sure @eroth, feel free to send a pull request for the step https://github.com/bitrise-io/steps-timestamp or create a #feature-request! :slight_smile:

P.S. a simple Script step can also be used with envman to expose the env var (http://devcenter.bitrise.io/tips-and-tricks/expose-environment-variable/), e.g. something like:

#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x

envman add --key=MY_TIMESTAMP --value="$(date +"%m-%d-%y")"

This will expose the date output into the env var MY_TIMESTAMP which can be used in subsequent steps.

Couple of date format options & examples: https://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/

1 Like

Great, thanks for the help!

1 Like

Any time @eroth! :wink: