vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Timestamp help (https://vborg.vbsupport.ru/showthread.php?t=77337)

Adrian Schneider 03-02-2005 03:24 PM

Timestamp help
 
A few questions with Linux timestamps.

How do you insert them into mySQL, using time(), date() or just an empty row?

My timestamps are looking like this: 20050302171707 - while this looksaccurate seeing as how it is 2005 - 3rd month - 2nd day, my friend saysthat is completely inaccurate. He then pointed me to this link to proove himself correct.

So what's the deal....:ermm:

sabret00the 03-02-2005 03:39 PM

to insert a timestamp into SQL you need to escape it as with any variable really but just use
PHP Code:

'" . TIMENOW . "' 

that's the vB version (pre escaped for ya)

Adrian Schneider 03-02-2005 03:43 PM

Thanks, I'll give this a shot.

So is the timestamp I am currently getting a crazy coincidence? Or just a unusable timestamp?

filburt1 03-02-2005 03:45 PM

Your timestamp is formatted with separate fields. A UNIX timestamp (seconds since January 1st, 1970) is only a scalar value.

Adrian Schneider 03-02-2005 04:14 PM

Well I tried your suggestion - and read a thread about iton filburts website - no luck yet. I checked the field type andit is TIMESTAMP(14). I tried '" . TIMENOW . "' with and withoutthe single quotes, I get different values for each. I even triedinserting the value a few ways into phpMyAdmin (even the UNIX_TIMESTAMPfunction) - still got the number below.

I think with the single quotes I'd get no value returned (000...) and without I'd get 20001112070437.

Any more info needed to sort this out let me know. It's really buggin me.:ermm:

sabret00the 03-02-2005 04:28 PM

you can just use time() if you're running the query straight but you'll even need to escape that

here's an example of entering this query
PHP Code:

    $DB_site->query("
        INSERT INTO table(userid, time)
        VALUES (
$bbuserinfo[userid], " TIMENOW ")
    "
); 

ooops i guess i didn't use the apostraphies, oh well i know that works :)

Adrian Schneider 03-02-2005 04:39 PM

Query:

PHP Code:

$creategame $DB_site->query("
INSERT INTO fc_game (gamename, creator, gametype,  matches, datecreated) VALUES ('
$gamename', '$creator', '$gametype', '$matches', "TIMENOW .") 
                                           "


Which Returns:
20001112072628

:ermm:

sabret00the 03-02-2005 04:46 PM

that be the case what's the problem?

Adrian Schneider 03-02-2005 04:48 PM

converted "20001112072628" to..
19 January 2038 03:14:07 AM

^^ problem, unless I've been asleep for a few years

sabret00the 03-02-2005 04:54 PM

ooooooh, major crash and burn

you sure the time is correct on your server?


All times are GMT. The time now is 05:57 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02523 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete