You really should separate the questions, and not ask two completely different questions at the same time.
How do you convert epoch time (unix timestamp) to standard time in D?
If you need to convert from unix time to SysTime "std time", then you use unixTimeToStdTime :
assert(unixTimeToStdTime(0) == (Date(1970, 1, 1) - Date.init).total!"hnsecs");
So, if you do SysTime(unixTimeToStdTime(0)) , you will get SysTime in your local time zone at the moment when it was midnight, January 1, 1970 in UTC (i.e. the time of the era). Unlike other SysTime constructors, it does not handle the time it gave as being in the time zone it gave. Rather, it simply sets its stdTime to a given value, and timezone to a given value. So, to build an identical SysTime with other constructors, you would do something like
auto epochInLocalTime = SysTime(Date(1970, 1, 1), UTC()).toLocalTime();
If you want to convert in the opposite direction, stdTimeToUnixTime converts std time to unix time. However, SysTime has toUnixTime on it, making it so that you don't need stdTimeToUnixTime at all.
time_t epoch = epochInLocalTime.toUnixTime();
However, one thing you need to know about is the fact that std.datetime does deal with unix time - time_t always counted in UTC. The reason this matters is because, for some inexplicable reason, Windows applies the local DST time to time_t , so the UTC offset never changes, which means it's wrong for a good piece of the year. It works with all Microsoft functions that use time_t because they expect this nonsense, but you will have compatibility issues if you try to use Windows time_t with another field or with a library like std.datetime, which is actually correct uses time_t .
Is there a way to customize the format?
Do you mean that you are looking for a way to provide a custom format for a string representing time (e.g. C strftime )? Std.datetime does not have this yet. An API still needs to be developed for this. Some discussion has taken place, but it has not yet been settled. Thus, this will happen eventually, but it may happen for a while.
In the interim, you have toISOString , toISOExtString and toSimpleString , which use the ISO format, the extended ISO format, and accordingly the Boost formatting format. In general, I would suggest using toISOExtString because it is easy to read by people and the standard. As a rule, it is best to place it in UTC format (for example, sysTime.toUTC() ) when communicating with other computers (as opposed to printing it to people), because then the time zone is part of it, unlike LocalTime , which is not "t add the time zone.
If you have not read this article in std.datetime , then I suggest you do it, as this should give you a good overview of the module and how to use it.