0

I would like to use date in the following format: yyyyMM.dd.HHmm. i.e. 202008.15.1742

This is the Bash file:

#!/usr/bin/env bash
VERSION_CODE=$((($(date +%s%N)/1000000))
plutil -replace CFBundleVersion -string "$VERSION_CODE"

How do I set VERSION_CODE such that the current time appears in this format: yyyyMM.dd.HHmm?

Cyrus
  • 77,979
  • 13
  • 71
  • 125
user1107173
  • 9,626
  • 14
  • 67
  • 111

2 Answers2

5

A pure Bash solution without spawning a sub-process:

printf -v VERSION_CODE '%(%Y%m.%d.%H%M)T'
Léa Gris
  • 14,880
  • 4
  • 28
  • 36
2

You can do it like this:

VERSION_CODE=$(date +"%Y%m.%d.%H%M")
1218985
  • 6,880
  • 2
  • 22
  • 27