Skip to content

Instantly share code, notes, and snippets.

@sayedihashimi
Created March 23, 2012 03:02
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save sayedihashimi/2166385 to your computer and use it in GitHub Desktop.
Save sayedihashimi/2166385 to your computer and use it in GitHub Desktop.
MSBuild how to get a good formatted date
<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0"
DefaultTargets="Demo" >
<Target Name="Demo">
<PropertyGroup>
<CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd-mmss))</CurrentDate>
</PropertyGroup>
<Message Text="CurrentDate: $(CurrentDate)"/>
</Target>
</Project>
@christianarg
Copy link

thanks for the tip. You missed the hour though

@MassimoSporchia
Copy link

Nice!

@dss539
Copy link

dss539 commented Mar 27, 2017

Thanks!

@dmytro-dovhan
Copy link

thanks

@kevinheyvaert
Copy link

What I was looking for. Thanks

@baruchiro
Copy link

Thnaks

@bvamos
Copy link

bvamos commented Sep 16, 2020

Unix timestamp:
$([MSBuild]::Subtract($([System.Math]::Floor($([MSBuild]::Divide($([System.DateTime]::UtcNow.Ticks), 10000000)))), 62135596800))

@pccai
Copy link

pccai commented Mar 17, 2022

$([MSBuild]::Subtract($([System.Math]::Floor($([MSBuild]::Divide($([System.DateTime]::UtcNow.Ticks), 10000000)))), 62135596800))
tks.

@VAllens
Copy link

VAllens commented May 17, 2022

Ohhhhh....
Nice!!!!!!!
Thanks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment