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
  • 84,225
  • 14
  • 89
  • 153
user1107173
  • 10,334
  • 16
  • 72
  • 117

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
  • 17,497
  • 4
  • 32
  • 41
2

You can do it like this:

VERSION_CODE=$(date +"%Y%m.%d.%H%M")
1218985
  • 7,531
  • 2
  • 25
  • 31