Jump to content

Recommended Posts

Posted

Hello

I have this date : 2024-03-17 10:58:40

Can you please say me how to convert in timestamp ?

In google i show time stamp to date only.

__AND__

An i have 2 date :

2024-04-17 10:58:40
2024-03-17 10:58:40

 

How to subtract thiis date please

 

THX

Posted

An (Unix) Timestamp is simply the difference (in seconds) between the date and the "epoch", which is 1970-01-01 00:00:00.

You could use Date.au3 to calculate it:

_DateDiff("s", "1970-01-01 00:00:00", "2024-03-17 10:58:40")

The same goes to find the difference between two dates.

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Posted

Thak you.

If i check i show : 1710673120

1710673120 is in secopnde or miliseconde ?

And how to convert this number in days / Hours / Minutes ?

 

Thank you

 

Posted

Take a look at the Help file and read the _DateDiff documentation. You can specify what you really want returned. In my example, I used "s" for seconds.

That said, with basic math you can convert it to other units.

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Posted
3 hours ago, AutoDEV said:

If i check i show : 1710673120   -> is this in seconds or miliseconds ?

Always in seconds !

3 hours ago, AutoDEV said:

And how to convert this number in days / Hours / Minutes ?

#include <Date.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
Local $iDateCalc = _DateDiff("s", "1970-01-01 00:00:00", "2024-03-17 10:58:40")
ConsoleWrite("Timestamp : " & $iDateCalc & @CRLF)

; Convert Timestamp to Date/Time (here : 1710673120 ):
Local $sDateFromEpoch = _DateAdd('s', $iDateCalc, "1970/01/01 00:00:00")
ConsoleWrite("Date Time : " & $sDateFromEpoch & @CRLF)

 

It's all in the help, as @Jefrey has already suggested.

Posted

OK thank you i have understand.

But i have 2 date.

How to make for show year/days/hours:min:seconde because in function i need shose a month or days or...

I not found on google

 

Thank You

  • Moderators
Posted
42 minutes ago, AutoDEV said:

OK thank you i have understand.

But i have 2 date.

How to make for show year/days/hours:min:seconde because in function i need shose a month or days or...

I not found on google

 

Thank You

They're telling you to look at the Help File.  What does Google have to do with anything?

image.thumb.png.f9d3615f9ad0bfb576d3495766f51ff8.png

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

OK TY.

But i need know, days and time.

I no want just one

I have found this on google.

$expiredate = $a1Row[6]

$FutureTime = $expiredate
$days = _DateDiff("D", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $FutureTime)
$hours = _DateDiff("h", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $FutureTime)
$minutes = _DateDiff("m", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $FutureTime)
$seconds = _DateDiff("s", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $FutureTime)
$iDays = Int($seconds / 86400)
$iHours = Int(($seconds - ($iDays * 86400)) / 3600)
$iMinutes = Int((($seconds - ($iDays * 86400)) - ($iHours * 3600)) / 60)
$iSeconds = Int(((($seconds - ($iDays * 86400)) - ($iHours * 3600) - ($iMinutes * 60)) * 60) / 60)
MsgBox(0, "Time until..", $iDays & " Days, " & $iHours & " Hours, " & $iMinutes & " minutes, " & $iSeconds & " seconds")

My probleme is : how to add one beginner date and not now time, i think is $iDays who need edited.

 

TY

Posted
3 hours ago, AutoDEV said:

I have found this on google.

$expiredate = $a1Row[6]

$FutureTime = $expiredate
$days = _DateDiff("D", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $FutureTime)
$hours = _DateDiff("h", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $FutureTime)
$minutes = _DateDiff("m", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $FutureTime)
$seconds = _DateDiff("s", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $FutureTime)
$iDays = Int($seconds / 86400)
$iHours = Int(($seconds - ($iDays * 86400)) / 3600)
$iMinutes = Int((($seconds - ($iDays * 86400)) - ($iHours * 3600)) / 60)
$iSeconds = Int(((($seconds - ($iDays * 86400)) - ($iHours * 3600) - ($iMinutes * 60)) * 60) / 60)
MsgBox(0, "Time until..", $iDays & " Days, " & $iHours & " Hours, " & $iMinutes & " minutes, " & $iSeconds & " seconds")

 

This code snippet throws error messages. It is therefore obvious that you have not started it once . 

Try this :

#include <Date.au3>

; Based on the date values in your first post :
;   Date 1 = 2024-04-17 10:58:40
;   Date 2 = 2024-03-17 10:58:40
; Your question : How to subtract these dates ?


Local $iDiffSec, $iDays, $iHours, $iMinutes, $iSeconds

$iDiffSec = _DateDiff("s", "2024-04-17 10:58:40", "2024-03-17 10:58:40")
$iDays    = Int($iDiffSec / 86400)
$iHours   = Int(($iDiffSec - ($iDays * 86400)) / 3600)
$iMinutes = Int((($iDiffSec - ($iDays * 86400)) - ($iHours * 3600)) / 60)
$iSeconds = Int(((($iDiffSec - ($iDays * 86400)) - ($iHours * 3600) - ($iMinutes * 60)) * 60) / 60)
MsgBox(0, "Time until..", $iDays & " Days, " & $iHours & " Hours, " & $iMinutes & " minutes, " & $iSeconds & " seconds")

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...