Jump to content
  • 0

Is this possible gettimestr("%Y-%m-%d %H:%M:%S",21) -> gettimetick and back


Phenomena

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  94
  • Reputation:   4
  • Joined:  10/31/12
  • Last Seen:  

Is this possible gettimestr("%Y-%m-%d %H:%M:%S",21) -> gettimetick and back?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

What format are your `start_date` and `end_date` columns?

If they are YYYY-MM-DD HH:MM:SS then you should us FROM_UNIXTIME() to convert from UNIX timestamp to Date-Time format.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

You could use query_sql and MySQL's functions:

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  94
  • Reputation:   4
  • Joined:  10/31/12
  • Last Seen:  

So, as i correctly check mysql manual:

 

                set .account_id, getcharid(3);
		query_sql "SELECT `userid` FROM `login` WHERE `account_id` = '"+ escape_sql( .account_id )+"'", .account_name$ ;
		set .start_time, gettimetick(2);
		set .end_time, .start_time + 600;	// 10 minutes
		mes "[ Meneger ]";
		mes "Account ID: " + .account_id;
		mes "Login: " + .account_name$;
		mes "Time start (UNIX): " + .start_time;
		mes "Time end (UNIX): " + .end_time;
		mes gettimestr("%Y-%m-%d %H:%M:%S",21);
		query_sql "INSERT INTO `account_type` ( `account_id`, `account_name`, `start_date`, `end_date`, `status` ) VALUES ( " + .account_id + ", '"+ escape_sql( .account_name$ )+"', UNIX_TIMESTAMP(" + .start_time + "), UNIX_TIMESTAMP(" + .end_time + "), 1 ) ";

Is this correct?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  94
  • Reputation:   4
  • Joined:  10/31/12
  • Last Seen:  

CREATE TABLE IF NOT EXISTS `account_type` (  `account_id` int(11) unsigned NOT NULL default '0',  `account_name` varchar(255) NOT NULL default 'NULL',  `start_date` datetime NOT NULL default '0000-00-00 00:00:00',  `end_date` datetime NOT NULL default '0000-00-00 00:00:00',  `status` varchar(255) NOT NULL DEFAULT 'NULL',  PRIMARY KEY  (`account_id`)) ENGINE=MyISAM;
start_date and end_date in %Y-%m-%d %H:%M:%S format,

so its must be FROM_UNIXTIME(" + .start_time + ")?

will try now...

its work, will make some tests, thank you!

Edited by Phenomena
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...