Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Time & PERL Time

Status
Not open for further replies.

1DMF

Programmer
Joined
Jan 18, 2005
Messages
8,795
Location
GB
This question is a cross between and I has already started it in the VBA forum, but thought one of you guys might be able to shed some light.

here is the link thread705-1091425
 
This might be what you're looking for

HTH
--Paul

cigless ...
 
Paul you can't be serious, all I want is the current time in amount of seconds passed since the official start time of 01/01/1970.

the example you show has a tonne of functions, declares to DLL's and hundreds of lines of code.

All you do in PERL is ...
Code:
my $time = time;

surely it's just as simple in VBA, I'm starting to feel faint!
 
I was just posting this as a good grounding on the two date formats.

I just scanned the article, and read a few of the code comments, and it seemed to be just that - sorry ;-)

Look up the HTML::Date, Date::Manip or Date::Calc, and these can generate strings to be compared in VB, or can take strings from VB and change them into epoch based unix dates

HTH
--Paul

cigless ...
 
I can't work out why but I have found that the results are different by exactly an hour.

I checked with my webhost and they confirm the server is on the correct time, yet VBA is simply using my computer time and that is the correct time.

but if I take the EPOCH date from VBA with
Code:
DateDiff("s",#01/01/1970#,Now())

and then use a script i threw together to process EPOCH datetime stamps like so
Code:
sub timedate {

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($timestamp);
      $year += 1900;
      if($mday < 10){$mday ="0".$mday;}
      if($mon < 10){$mon ="0".$mon;}
      $date="$mday / $mon / $year";
	if($hour < 9){$hour = "0$hour";}
	if($min < 9){$min = "0$min";}
	if($sec < 9){$sec = "0$sec";}

      $time=" - $hour : $min : $sec";

if($date eq "0 / 0 / 1900"){$date = "Invalid Timestamp"; $time="";}
else{print "$date$time"; exit();}

where $timestamp = the VBA EPOCH number produced, there is an hours difference.

Oh well if it stays constant then the maths is easy to do , but why the difference. beats me!
 
You'll need to account for timezones and Summer time, these scripts work GREAAT in the winter

Here check out gmtime();

Don't forget to put both your clocks forward to test for the end of summer ;-)

HTH
--Paul
 
Yeah I know about time zones Paul, but seings as we are both in the UK and so is the web server, DST should mean nothing, we are all on the same time here, the UK only has one time zone!
 
2 actually BST and UTC (formerly GMT)
HTH
--Paul

cigless ...
 
I have decided that maybe i shall use ANSI format as suggested by a kind fellow in the VBA forum.

what the hell is UTC, GMT is GMT it stands for Greenwich Mean Time and is because Greenwich is ZERO on the logitude Latitude scale (Which ever way rounf it is) and so cannot change.

I bet brussels had something to do with that - lol, they'll be saying we got to change the nautical map next just to make Europe the center of the world!

All I want to do is a simple time calculation, why does politics always have to spoil things!

Take it easy Paul, thanks for the input. regards, 1DMF
 
UTC coordinated universal time

I think it was actually the Americans in conjunction with the Europayans

GMT is being deprecated, just so's you know

;-)
--Paul

cigless ...
 
GMT is just like Hardcore - Will Never Die!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top