Jump to content

Convert Date and Time to Seconds


laurin1
 Share

Recommended Posts

You can copy the UDF from here.

Just a small sample to use, with the included UDF

$sType='s'
$sStartDate='2004/12/01 12:00:00'
$sEndDate='2004/12/01 12:01:00'
$ans= _DateDiff($sType, $sStartDate, $sEndDate)
MsgBox(0, 'Seconds', 'Equals ' & $ans)

<{POST_SNAPBACK}>

I don't understand. When I run your sample, the answer is 60. I want to take a date and convert it into seconds.

Keith Davis

MCSA, ZCE, A+, N+

http://www.laurinkeithdavis.com

Link to comment
Share on other sites

$sType is the variable for hours, minutes or seconds selection.

$sStartDate is the variable for Start Date.

$sEndDate is the variable for Finish Date.

$ans is the result of into the UDF script to create the difference in seconds, between the 2 dates.

The 60 returned is 60 seconds.

This gives you date/time difference in seconds?

Could you express more, if insuffient.

Link to comment
Share on other sites

  • Developers

I don't understand. When I run your sample, the answer is 60. I want to take a date and convert it into seconds.

<{POST_SNAPBACK}>

You will need a start date to determine the number of seconds elapsed since...

The Date functions currently only accept a date between 1900 - 2999 .

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

This is the area of interest in the UDF

; Description:      Returns the difference between 2 dates, expressed in the type requested

; Parameter(s):    $sType - returns the difference in:

;                              d = days

;                              m = Months

;                              y = Years

;                              w = Weeks

;                              h = Hours

;                              n = Minutes

;                              s = Seconds

;                  $sStartDate    - Input Start date in the format "YYYY/MM/DD[ HH:MM:SS]"

;                  $sEndDate    - Input End date in the format "YYYY/MM/DD[ HH:MM:SS]"

; Requirement(s):  None

; Return Value(s):  On Success - Difference between the 2 dates

;                  On Failure - 0  and Set

;                                  @ERROR to:  1 - Invalid $sType

;                                              2 - Invalid $sStartDate

;                                              3 - Invalid $sEndDate

; Author(s):        Jos van der Zande

JdeB coded it, btw. :idiot:
Link to comment
Share on other sites

I don't understand how you can convert a Date into seconds. maybe Time, but date from when?

My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...