Hi,
I am trying to replicate the Unix Timestamp,specifically the function
mktime() in Vbscript, ASP. I have the following so far:
ThisTime = DateSerial(2004, 9, 27) + TimeSerial(0, 0, 0)
response.write DateDiff("s", "12/31/1969 00:00:00", ThisTime)
This returns the timestamp: 1096329600, and when you decode that it comes
to: 27 Sep 2004 20:00. I want to set the time too, ie. show for example: 27
Sep 2004 16:15
Any ideas?
Thanks,
Shahid
(remove the words "REMOVETHIS" when replying to email address) 5 14892
*Shahid Juma* wrote in microsoft.public.inetserver.asp.general: I am trying to replicate the Unix Timestamp,specifically the function mktime() in Vbscript, ASP. I have the following so far:
ThisTime = DateSerial(2004, 9, 27) + TimeSerial(0, 0, 0) response.write DateDiff("s", "12/31/1969 00:00:00", ThisTime)
This returns the timestamp: 1096329600, and when you decode that it comes to: 27 Sep 2004 20:00. I want to set the time too, ie. show for example: 27 Sep 2004 16:15
Any ideas?
Why not just invoke a JScript function from within your VBScript since
JScript dates follow the same Unix format (AFAIK)?
<script language="JScript" runat="server">
function GetUnixTime(strDate) {
if (strDate) {
return new Date(strDate).valueOf();
}
else {
return 0;
}
}
</script>
<%=GetUnixTime("Tue, 28 Sep 2004 14:45:28 GMT")%>
(not tested)
--
Andrew Urquhart
- FAQ: http://www.aspfaq.com
- Archive: http://andrewu.co.uk/r/?6 (Google Groups)
- Contact me: http://andrewu.co.uk/contact/
"Andrew Urquhart" <us**************************@com.invalid> wrote in
message news:18***************@usenet.andrewu.co.uk... *Shahid Juma* wrote in microsoft.public.inetserver.asp.general: I am trying to replicate the Unix Timestamp,specifically the function mktime() in Vbscript, ASP. I have the following so far:
ThisTime = DateSerial(2004, 9, 27) + TimeSerial(0, 0, 0) response.write DateDiff("s", "12/31/1969 00:00:00", ThisTime)
This returns the timestamp: 1096329600, and when you decode that it
comes to: 27 Sep 2004 20:00. I want to set the time too, ie. show for example:
27 Sep 2004 16:15
Any ideas?
Why not just invoke a JScript function from within your VBScript since JScript dates follow the same Unix format (AFAIK)?
<script language="JScript" runat="server"> function GetUnixTime(strDate) { if (strDate) { return new Date(strDate).valueOf(); } else { return 0; } } </script> <%=GetUnixTime("Tue, 28 Sep 2004 14:45:28 GMT")%>
(not tested) -- Andrew Urquhart - FAQ: http://www.aspfaq.com - Archive: http://andrewu.co.uk/r/?6 (Google Groups) - Contact me: http://andrewu.co.uk/contact/
Thanks, that did work, however, it returns back a value that is 13 in
length. In PHP,it returns it with length of 10. I just took the first 10 and
it did work. Is there any other way? Besides doing it this way?
Thanks,
Shahid
A follow up to this question...
How do I convert it back and print the date, basically decode it.
Shahid
"Andrew Urquhart" <us**************************@com.invalid> wrote in
message news:1h****************@usenet.andrewu.co.uk... *Shahid Juma* wrote in microsoft.public.inetserver.asp.general: Thanks, that did work, however, it returns back a value that is 13 in length. In PHP,it returns it with length of 10. I just took the first 10
and it did work.
That's the difference between seconds and milliseconds
Is there any other way? Besides doing it this way?
http://www.aspfaq.com/show.asp?id=2219 -- Andrew Urquhart - FAQ: http://www.aspfaq.com - Archive: http://andrewu.co.uk/r/?6 (Google Groups) - Contact me: http://andrewu.co.uk/contact/
*Shahid Juma* wrote: A follow up to this question...
How do I convert it back and print the date, basically decode it.
In JScript (and javascript) the date object can take a unix integer date
as the constructor parameter in addition to the various string inputs.
E.g.: var objDate = new Date(1096925521646); // Argument is in ms, not s
If your value is in seconds, multiple it first by 1000 to get the
required milliseconds input value. After creating the date object you
can format it using the plethora of available date methods. However,
one of the quickest ways of getting a string result is to use:
var strDate = objDate.toUTCString();
For the list of date methods see: http://msdn.microsoft.com/library/en...6jsobjdatemeth
--
Andrew Urquhart
- FAQ: http://www.aspfaq.com
- Archive: http://www.google.com/groups?group=m...er.asp.general
- Contact: http://andrewu.co.uk/contact/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Yang Li Ke |
last post by:
Hi guys,
Im about to build a script which will log visitor time spent on my website.
I got a few ideas about this, maybe checking visitors ip and storing that
info in db with time in and then...
|
by: lkrubner |
last post by:
I just noticed this when I was catching up on old posts:
>Senator Jay Billington Bulworth Feb 3, 6:09 am
>function getmicrotime(){
> list($usec, $sec) = explode(' ', microtime());
> ...
|
by: Don |
last post by:
Hi all,
With regards to the following, how do I append the datetimestamp to
the filenames in the form? The files are processed using the PHP
script that follows below.
Thanks in advance,...
|
by: sumeet |
last post by:
how do i convert a yyyymmdd format to yyyy,mm,dd format. also i want to know how do i get the number of days between two dates which r in the format yyyymmdd.
how to convert date into unix time...
|
by: Shahid Juma |
last post by:
Is there any way to get the Unix Time Stamp in ASP.NET. I am using C#.
Thanks,
Shahid
| |
by: Mike Charney |
last post by:
Is there a way to check a files date and time stamp from VBA in access.
I have a need check a date stamp on a file that I am importing.
Thanks in advance,
Mike
m charney at dunlap hospital...
|
by: phried1 |
last post by:
I have created a form and inserted the following tables:
Date Entered
Time Entered
Date Modified
Time Modified
Essentially how and where can I have these dates and times recorded so when the...
|
by: SilentThunderer |
last post by:
Hey folks,
Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
|
by: Shane |
last post by:
I'm writing a program for renaming my picture files, and I want to use
the picture time stamp as a prefix to the file names. I can get the
time stamp, but it is extraordinarily slow! I have about...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |