vb.org Archive

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

Dean C 05-11-2003 12:36 PM

UNIX timestamps
 
I worked out thanks to someone here at .org how to put a unix timestamp into a readable format with the date() function :)

Now say if im inserting time() into a field in a table

e.g.

[sql]
UPDATE timer SET time='".time()."';
[/sql]

How would i adapt that query to add a year to the current time?

Thanks in Advance

- miSt

Dean C 05-11-2003 12:37 PM

WTF bug in the sql code alert ;)

It was meant to read:

UPDATE timer SET time='"time()'";

- miSt

Xenon 05-11-2003 01:19 PM

erm. '". isn't a sql query, you are trying to mix up php and mysql so you should use php or code tags :)

updateing timefield to add a year:
[sql]UPDATE timer SET time=time+3600*24*356[/sql]

SiGmA_X 05-14-2003 12:02 AM

Hang on, time() doesn't have a year in it? It says it does, and in practice seems to, because it records the amount of seconds from the Epoch, which would include a year. Right? I think miSt's idea of just using time() is correct.

But that's just my 2 cents :)

filburt1 05-14-2003 12:10 AM

time() returns a date in epochs which implicitly has the year.

Dean C 05-14-2003 03:40 PM

I had to do this in the end ;)

PHP Code:

$DB_site->query("UPDATE secrettable SET secretfield=(time()+31536000) WHERE userid=$userid"); 

- miSt

SiGmA_X 05-14-2003 03:54 PM

What does the +3153600 do? Being the time is from the Epoch, it will have year.. I am still unsure why you are adding the extra numbers in :\

Dean C 05-14-2003 03:59 PM

It simply adds a year to the current timestamp outputted from the time() function :)

- miSt


All times are GMT. The time now is 08:03 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.00938 seconds
  • Memory Usage 1,720KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete