Unix Time Stamp

Discussion in 'ASP General' started by Shahid Juma, Sep 28, 2004.

  1. Shahid Juma

    Shahid Juma Guest

    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)
     
    Shahid Juma, Sep 28, 2004
    #1
    1. Advertising

  2. Shahid Juma

    Shahid Juma Guest

    "Andrew Urquhart" <> wrote in
    message news:...
    > *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
     
    Shahid Juma, Sep 28, 2004
    #2
    1. Advertising

  3. Shahid Juma

    Shahid Juma Guest

    A follow up to this question...

    How do I convert it back and print the date, basically decode it.

    Shahid

    "Andrew Urquhart" <> wrote in
    message news:1hfttct3zxit3$...
    > *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, Oct 4, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ladygrinningsoul

    Modifying a file's time stamp

    ladygrinningsoul, Dec 5, 2004, in forum: Perl
    Replies:
    1
    Views:
    561
    ladygrinningsoul
    Dec 6, 2004
  2. =?Utf-8?B?QmVydA==?=

    Date/Time stamp in SQL

    =?Utf-8?B?QmVydA==?=, Jan 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    21,468
    Wardeaux
    Jan 30, 2004
  3. Zean Smith

    Time stamp problem

    Zean Smith, Feb 7, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    347
    Zean Smith
    Feb 7, 2006
  4. srini
    Replies:
    9
    Views:
    11,646
    Beauregard T. Shagnasty
    Apr 14, 2004
  5. BartlebyScrivener

    shutil.copy time stamp errors on win XP

    BartlebyScrivener, Apr 15, 2006, in forum: Python
    Replies:
    2
    Views:
    398
    BartlebyScrivener
    Apr 16, 2006
Loading...

Share This Page