Convert String to Date and Add ±N Hours
Steven Schveighoffer
schveiguy at gmail.com
Sat Nov 4 21:10:38 UTC 2023
On Saturday, 4 November 2023 at 18:11:53 UTC, Vahid wrote:
> Hi,
>
> I have a date string with the format of "2023-11-04 23:10:20".
> I want to convert this string to Date object and also, add ±N
> hours to it. For example:
>
> `"2023-11-04 23:10:20" + "+2:00" = "2023-11-05 01:10:20"`
> `"2023-11-04 23:10:20" + "-2:30" = "2023-11-05 20:40:20"`
>
> How can I do this?
Parse the date. There is a nice package on code.dlang.org that is
for date parsing: https://code.dlang.org/packages/dateparser
-Steve
More information about the Digitalmars-d-learn
mailing list