vb.org Archive

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

veenuisthebest 08-14-2008 02:02 AM

vbdate() function
 
I am not able to retrieve the current time according to user's timezone settings using vbdate()

I am using this, but this always shows 01st of January, 1970:-

PHP Code:

$timestamp vbdate("jS \of F, Y h:i:s A"$result['TIMESTAMP']); 

Then I use this, and it works fine but always show time 5 hours back.

PHP Code:

$eventdate strtotime($result['TIMESTAMP']);
$timestamp vbdate("jS \of F, Y h:i:s A"$eventdate); 

What wrong am I doing? To insert current time, i have simply created a column of datatype TIMESTAMP and it inserts fine.

Thank You

MoT3rror 08-14-2008 03:43 AM

vbdate function takes UNIX time not in a format such as YYYY-MM-DD HH:MM:SS which is returned by mysql when a column is in date format.

veenuisthebest 08-14-2008 09:04 AM

so how to solve the problem ? please explain programmatically. How to insert current date/time so that vbdate() works.

Marco van Herwaarden 08-14-2008 09:21 AM

Make the database column an integer(11), use TIMENOW as current value to insert and use vbdate() to make it a displayable date in the users TZ.

veenuisthebest 08-15-2008 11:29 AM

Thank you, it works great now.

Is there a way to do just the vice versa of it ? Now I want to convert the displayed form into unix timestamp format and insert it, how should I do it ??

This is the process what I want to do:-

1. Insert date in unix format.
2. Retrieve it in desired format with vbdate().
3. Edit the retrieved date.
4. On submit, convert it in unix timestamp and insert it.

Need help with steps 3 and 4.

Thank You

Marco van Herwaarden 08-16-2008 09:18 AM

You can use the mktime() function or better the vbmktime() wrapper.


All times are GMT. The time now is 02:12 PM.

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.02359 seconds
  • Memory Usage 1,719KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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