473,231 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Unix Time Stamp

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)
Jul 19 '05 #1
5 14820
*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/
Jul 19 '05 #2

"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
Jul 19 '05 #3
*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/
Jul 19 '05 #4
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/

Jul 19 '05 #5
*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/
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
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...
1
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()); > ...
7
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,...
0
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...
0
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
6
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...
3
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...
4
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...
2
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...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.