PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Convert string milliseconds in date
Convert string milliseconds in date
Débuté par lbidi, 18 avr. 2018 22:32 - 2 réponses
Membre enregistré
18 messages
Posté le 18 avril 2018 - 22:32
Hi.. I have a string with milliseconds format, that its returned from a web service that I need to convert to date.

for ex the string is "201804181084313", how can I convert it to a valid date ?

Thanks.
Membre enregistré
16 messages
Posté le 27 avril 2018 - 19:31
Hi lbidi

from your string:
2018 - year
04 - month
18 - day
10 - hour
84 - minute???
that string is surely not correct but if it was, it would be something like this:

sTest is string="20180427182414836"

dDate is Date
tTime is Time

dDate=Left(sTest,8)
tTime=Middle(sTest,9)

Info("Date: "+DateToString(dDate,"DD/MM/YYYY")+CR+"Time: "+TimeToString(tTime,"HH:MM:SS:CC"))


"20180427182414836"
2018 - year
04 - month
27 - day
18 - hour
24 - minutes
14 - seconds
836 - milliseconds
Membre enregistré
18 messages
Posté le 27 avril 2018 - 20:31
Hi Jose.. That example was not valid, I just made up for the post.

I've resolved my problem with this..

rNumber is the value that the web service returns , its a date value in milliseconds format.

dToday..Second += ( rNumber / 1000 )

then in dTotay..Date , I have the date I was looking for.

Many Thanks anyway !!
Message modifié, 27 avril 2018 - 20:33